Module: EMRPC::RemoteConnection
- Includes:
- ConnectionMixin
- Defined in:
- lib/emrpc/evented_api/remote_connection.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
Attributes included from ConnectionMixin
#connected_callback, #disconnected_callback, #local_pid, #remote_pid
Instance Method Summary collapse
-
#connection_completed ⇒ Object
Handshake protocol.
-
#post_init ⇒ Object
IMPORTANT: server doesn’t trigger #connection_completed callback.
- #receive_handshake_message(msg) ⇒ Object
- #receive_regular_message(msg) ⇒ Object
- #rescue_marshal_error(e) ⇒ Object
- #send_handshake_message(arg) ⇒ Object
-
#send_raw_message(args) ⇒ Object
Regular protocol.
- #unbind ⇒ Object
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
4 5 6 |
# File 'lib/emrpc/evented_api/remote_connection.rb', line 4 def address @address end |
Instance Method Details
#connection_completed ⇒ Object
Handshake protocol
19 20 21 |
# File 'lib/emrpc/evented_api/remote_connection.rb', line 19 def connection_completed (@local_pid.) end |
#post_init ⇒ Object
IMPORTANT: server doesn’t trigger #connection_completed callback.
9 10 11 12 13 14 |
# File 'lib/emrpc/evented_api/remote_connection.rb', line 9 def post_init # setup single-shot version of receive_marshalled_message class <<self alias_method :receive_marshalled_message, :receive_handshake_message end end |
#receive_handshake_message(msg) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/emrpc/evented_api/remote_connection.rb', line 28 def (msg) prefix, = msg lpid = @local_pid prefix == :handshake or return lpid.handshake_failed(self, msg) rpid = RemotePid.new(self, ) # restore receive_marshalled_message class <<self alias_method :receive_marshalled_message, :receive_regular_message end unless @__sent_handshake # server-side (@local_pid.) end @remote_pid = lpid.connection_established(rpid, self) end |
#receive_regular_message(msg) ⇒ Object
50 51 52 53 |
# File 'lib/emrpc/evented_api/remote_connection.rb', line 50 def (msg) lpid = @local_pid lpid.__send__(*(msg.decode_b381b571_1ab2_5889_8221_855dbbc76242(lpid))) end |
#rescue_marshal_error(e) ⇒ Object
55 56 57 |
# File 'lib/emrpc/evented_api/remote_connection.rb', line 55 def rescue_marshal_error(e) raise e end |
#send_handshake_message(arg) ⇒ Object
23 24 25 26 |
# File 'lib/emrpc/evented_api/remote_connection.rb', line 23 def (arg) @__sent_handshake = true ([:handshake, arg]) end |
#send_raw_message(args) ⇒ Object
Regular protocol
46 47 48 |
# File 'lib/emrpc/evented_api/remote_connection.rb', line 46 def (args) (args.encode_b381b571_1ab2_5889_8221_855dbbc76242(@local_pid)) end |
#unbind ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/emrpc/evented_api/remote_connection.rb', line 59 def unbind if @remote_pid # pid has been succesfully connected one day, but connection was lost. # we don't put +_unregister_pid+ into +connection_lost+ callback to avoid unneccessary +super+ calls in callbacks. rpid = @remote_pid @remote_pid = nil @local_pid.connection_unbind(rpid, self) else # there were no connection, connecting failed. @local_pid.connection_failed(self) end end |