Class: AmfSocket::RpcMessage
- Inherits:
-
Object
- Object
- AmfSocket::RpcMessage
- Defined in:
- lib/amf_socket/rpc_message.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#message_id ⇒ Object
readonly
Returns the value of attribute message_id.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#sent_at ⇒ Object
readonly
Returns the value of attribute sent_at.
Instance Method Summary collapse
-
#initialize(command, params = {}) ⇒ RpcMessage
constructor
A new instance of RpcMessage.
- #to_hash ⇒ Object
Constructor Details
#initialize(command, params = {}) ⇒ RpcMessage
Returns a new instance of RpcMessage.
7 8 9 10 11 12 13 14 |
# File 'lib/amf_socket/rpc_message.rb', line 7 def initialize(command, params = {}) raise AmfSocket::InvalidArg.new('Command must be a String.') unless command.is_a?(String) raise AmfSocket::InvalidArg.new('Params must be a Hash.') unless params.is_a?(Hash) @command = command @params = params = SecureRandom.hex end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
3 4 5 |
# File 'lib/amf_socket/rpc_message.rb', line 3 def command @command end |
#message_id ⇒ Object (readonly)
Returns the value of attribute message_id.
2 3 4 |
# File 'lib/amf_socket/rpc_message.rb', line 2 def end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
4 5 6 |
# File 'lib/amf_socket/rpc_message.rb', line 4 def params @params end |
#sent_at ⇒ Object (readonly)
Returns the value of attribute sent_at.
5 6 7 |
# File 'lib/amf_socket/rpc_message.rb', line 5 def sent_at @sent_at end |
Instance Method Details
#to_hash ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/amf_socket/rpc_message.rb', line 16 def to_hash object = {} object[:type] = 'rpcMessage' object[:message] = {} object[:message][:messageId] = object[:message][:command] = command object[:message][:params] = params return object end |