Class: AMF::Pure::Request
- Inherits:
-
Object
- Object
- AMF::Pure::Request
- Includes:
- ReadIOHelpers
- Defined in:
- lib/amf/pure/remoting.rb
Overview
AMF request object wrapper, it is responsible for deserializing AMF requests
Instance Attribute Summary collapse
-
#amf_version ⇒ Object
readonly
Returns the value of attribute amf_version.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
-
#initialize ⇒ Request
constructor
A new instance of Request.
- #populate_from_stream(stream) ⇒ Object
Methods included from ReadIOHelpers
#byte_order, #byte_order_little?, #read_double, #read_int16_network, #read_int8, #read_word16_network, #read_word32_network, #read_word8
Constructor Details
#initialize ⇒ Request
Returns a new instance of Request.
9 10 11 12 |
# File 'lib/amf/pure/remoting.rb', line 9 def initialize @amf_version = 3 @headers = [] end |
Instance Attribute Details
#amf_version ⇒ Object (readonly)
Returns the value of attribute amf_version.
7 8 9 |
# File 'lib/amf/pure/remoting.rb', line 7 def amf_version @amf_version end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
7 8 9 |
# File 'lib/amf/pure/remoting.rb', line 7 def headers @headers end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
7 8 9 |
# File 'lib/amf/pure/remoting.rb', line 7 def end |
Instance Method Details
#populate_from_stream(stream) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/amf/pure/remoting.rb', line 14 def populate_from_stream(stream) stream = StringIO.new(stream) unless StringIO === stream # Read AMF version @amf_version = read_word16_network(stream) # Read in headers header_count = read_word16_network(stream) 0.upto(header_count-1) do name = stream.read(read_word16_network(stream)) must_understand = read_int8(stream) != 0 length = read_word32_network(stream) data = AMF.deserialize(stream) @headers << Header.new(name, must_understand, data) end # Read in first message = read_word16_network(stream) target_uri = stream.read(read_word16_network(stream)) response_uri = stream.read(read_word16_network(stream)) length = read_word32_network(stream) data = AMF.deserialize(stream) if data.is_a?(Array) && data.length == 1 && data[0].is_a?(::AMF::Messages::AbstractMessage) data = data[0] end = Message.new(target_uri, response_uri, data) self end |