Class: Lobster::Network::ResponseMessage

Inherits:
Message
  • Object
show all
Defined in:
lib/lobster/network/response_message.rb

Overview

Message sent as a reply to a request.

Instance Attribute Summary collapse

Attributes inherited from Message

#id, #name, #payload

Instance Method Summary collapse

Constructor Details

#initialize(id, request_id, name, payload = nil) ⇒ ResponseMessage

Creates a new response message.

Parameters:

  • id (Fixnum)

    Unique numerical ID of the message.

  • request_id (Fixnum)

    ID of the request this message is responding to.

  • name (String)

    Message type name.

  • payload (#to_json) (defaults to: nil)

    Any object that can be serialized to JSON.


18
19
20
21
22
23
# File 'lib/lobster/network/response_message.rb', line 18

def initialize(id, request_id, name, payload = nil)
  fail ArgumentError unless request_id.is_a?(Fixnum)

  super(id, name, payload)
  @request_id = request_id
end

Instance Attribute Details

#request_idFixnum (readonly)

ID of the original request this message is responding to.

Returns:

  • (Fixnum)

11
12
13
# File 'lib/lobster/network/response_message.rb', line 11

def request_id
  @request_id
end