def handle_request(message, notification=false, connection={})
    # get client for the specified connection
    # TODO should grap port/ip immediately on connection and use that
    client_port,client_ip = client_for(connection)

    msg = notification ?
      Messages::Notification.new(:message => message,
                                 :headers => @message_headers) :
           Messages::Request.new(:message => message,
                                 :headers => @message_headers)

    callback = NodeCallback.new(:node       => self,
                                :connection => connection)

    result = @dispatcher.dispatch(:rjr_method      => msg.jr_method,
                                  :rjr_method_args => msg.jr_args,
                                  :rjr_headers     => msg.headers,
                                  :rjr_client_ip   => client_ip,
                                  :rjr_client_port => client_port,
                                  :rjr_node        => self,
                                  :rjr_node_id     => node_id,
                                  :rjr_node_type   => self.node_type,
                                  :rjr_callback    => callback)

    unless notification
      response = Messages::Response.new(:id      => msg.msg_id,
                                        :result  => result,
                                        :headers => msg.headers,
                                        :request => msg)
      self.send_msg(response.to_s, connection)
      return response
    end

    nil
  end
def handle_request(message, notification=false, connection={})
    # get client for the specified connection
    # TODO should grap port/ip immediately on connection and use that
    client_port,client_ip = client_for(connection)

    msg = notification ?
      Messages::Notification.new(:message => message,
                                 :headers => @message_headers) :
           Messages::Request.new(:message => message,
                                 :headers => @message_headers)

    callback = NodeCallback.new(:node       => self,
                                :connection => connection)

    result = @dispatcher.dispatch(:rjr_method      => msg.jr_method,
                                  :rjr_method_args => msg.jr_args,
                                  :rjr_headers     => msg.headers,
                                  :rjr_client_ip   => client_ip,
                                  :rjr_client_port => client_port,
                                  :rjr_node        => self,
                                  :rjr_node_id     => node_id,
                                  :rjr_node_type   => self.node_type,
                                  :rjr_callback    => callback)

    unless notification
      response = Messages::Response.new(:id      => msg.msg_id,
                                        :result  => result,
                                        :headers => msg.headers,
                                        :request => msg)
      self.send_msg(response.to_s, connection)
      return response
    end

    nil
  end
Internal helper, handle request message received