Module: EMRPC::DefaultCallbacks

Included in:
Pid
Defined in:
lib/emrpc/evented_api/default_callbacks.rb

Defined Under Namespace

Classes: UndefinedCallback

Instance Method Summary collapse

Instance Method Details

#connected(pid) ⇒ Object

Called with some pid is connected to us (we are the server) or when we connect to another pid (we act as client). When two pids are connected, they act as client and server interchangably no matter who initiated connection.



7
8
# File 'lib/emrpc/evented_api/default_callbacks.rb', line 7

def connected(pid)
end

#connection_failed(conn) ⇒ Object

Called when pid failed connecting to the address Argument conn is the same what #connect(addr) returns. Address is contained in the conn.address



18
19
# File 'lib/emrpc/evented_api/default_callbacks.rb', line 18

def connection_failed(conn)
end

#disconnected(pid) ⇒ Object

Called when existing connection was lost (explicitely killed or crashed). The same pid passed, as in #connected callback.



12
13
# File 'lib/emrpc/evented_api/default_callbacks.rb', line 12

def disconnected(pid)
end

#handshake_failed(conn, msg) ⇒ Object

Called when pid responds incorrectly. Normally, this should not be called.



33
34
35
# File 'lib/emrpc/evented_api/default_callbacks.rb', line 33

def handshake_failed(conn, msg)
  raise "Hello failed in connection #{conn} with message #{msg.inspect} (expected [:hello, {:uuid => <UUID>}])"
end

#on_raise(pid, exception) ⇒ Object

Called when sync method raises exception.

Raises:



27
28
29
# File 'lib/emrpc/evented_api/default_callbacks.rb', line 27

def on_raise(pid, exception)
  raise UndefinedCallback, "#{self}.on_raise callback is undefined. Received: pid = #{pid}, exception = #{exception}."
end

#on_return(pid, value) ⇒ Object

Called when sync method returns value.

Raises:



22
23
24
# File 'lib/emrpc/evented_api/default_callbacks.rb', line 22

def on_return(pid, value)
  raise UndefinedCallback, "#{self}.on_return callback is undefined. Received: pid = #{pid}, value = #{value}."
end