Class: RJR::NodeCallback
Overview
Node callback interface, used to invoke json-rpc methods against a remote node via node connection previously established
After a node sends a json-rpc request to another, the either node may send additional requests to each other via the connection already established until it is closed on either end
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ NodeCallback
constructor
NodeCallback initializer.
- #notify(callback_method, *data) ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ NodeCallback
NodeCallback initializer
25 26 27 28 |
# File 'lib/rjr/node_callback.rb', line 25 def initialize(args = {}) @node = args[:node] @connection = args[:connection] end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
18 19 20 |
# File 'lib/rjr/node_callback.rb', line 18 def connection @connection end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
17 18 19 |
# File 'lib/rjr/node_callback.rb', line 17 def node @node end |
Instance Method Details
#notify(callback_method, *data) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rjr/node_callback.rb', line 30 def notify(callback_method, *data) # TODO throw error here ? return unless node.persistent? msg = Messages::Notification.new :method => callback_method, :args => data, :headers => @node. # TODO surround w/ begin/rescue block, # raise RJR::ConnectionError on socket errors @node.send_msg msg.to_s, @connection end |