class RJR::NodeCallback

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

Attributes

connection[R]
node[R]

Public Class Methods

new(args = {}) click to toggle source

NodeCallback initializer @param [Hash] args the options to create the node callback with @option args [node] :node node used to send messages @option args [connection] :connection connection to be used in

channel selection
# File lib/rjr/node_callback.rb, line 25
def initialize(args = {})
  @node        = args[:node]
  @connection  = args[:connection]
end

Public Instance Methods

notify(callback_method, *data) click to toggle source
# 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.message_headers

  # TODO surround w/ begin/rescue block,
  # raise RJR::ConnectionError on socket errors
  @node.send_msg msg.to_s, @connection
end