Class: AMF::Pure::Response
- Inherits:
-
Object
- Object
- AMF::Pure::Response
- Includes:
- WriteIOHelpers
- Defined in:
- lib/amf/pure/remoting.rb
Overview
AMF response object wrapper, it is responsible for serializing the AMF response
Instance Attribute Summary collapse
-
#amf_version ⇒ Object
Returns the value of attribute amf_version.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#message ⇒ Object
Returns the value of attribute message.
Instance Method Summary collapse
-
#initialize ⇒ Response
constructor
A new instance of Response.
- #serialize ⇒ Object
- #to_s ⇒ Object
Methods included from WriteIOHelpers
#byte_order, #byte_order_little?, #pack_double, #pack_int16_network, #pack_int8, #pack_integer, #pack_word32_network
Constructor Details
#initialize ⇒ Response
Returns a new instance of Response.
52 53 54 55 |
# File 'lib/amf/pure/remoting.rb', line 52 def initialize @amf_version = 0 @headers = [] end |
Instance Attribute Details
#amf_version ⇒ Object
Returns the value of attribute amf_version.
50 51 52 |
# File 'lib/amf/pure/remoting.rb', line 50 def amf_version @amf_version end |
#headers ⇒ Object
Returns the value of attribute headers.
50 51 52 |
# File 'lib/amf/pure/remoting.rb', line 50 def headers @headers end |
#message ⇒ Object
Returns the value of attribute message.
50 51 52 |
# File 'lib/amf/pure/remoting.rb', line 50 def @message end |
Instance Method Details
#serialize ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/amf/pure/remoting.rb', line 57 def serialize stream = "" # Write version stream << pack_int16_network(@amf_version) # Write headers stream << pack_int16_network(@headers.length) # Header count @headers.each do |h| stream << pack_int16_network(h.name.length) stream << h.name stream << pack_int8(h.must_understand ? 1 : 0) stream << pack_word32_network(-1) stream << AMF.serialize(h.data, 0) end # Write messages stream << pack_int16_network(1) # we only send one message stream << pack_int16_network(@message.target_uri.length) stream << @message.target_uri stream << pack_int16_network(@message.response_uri.length) stream << @message.response_uri stream << pack_word32_network(-1) stream << AMF0_AMF3_MARKER if @amf_version == 3 # stream << AMF.serialize(m.data, @amf_version) stream << @message.data stream end |
#to_s ⇒ Object
89 90 91 |
# File 'lib/amf/pure/remoting.rb', line 89 def to_s serialize end |