Class: RocketAMF::Pure::Deserializer

Inherits:
Object
  • Object
show all
Includes:
IOHelperRead
Defined in:
lib/rocketamf/pure/deserializer.rb

Overview

Pure ruby deserializer for AMF3 requests

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from IOHelperRead

#read_double, #read_int16_network, #read_int8, #read_word16_network, #read_word32_network, #read_word8

Methods included from IOHelperBase

#byte_order, #byte_order_little?

Constructor Details

#initialize(class_mapper) ⇒ Deserializer

Returns a new instance of Deserializer.



25
26
27
# File 'lib/rocketamf/pure/deserializer.rb', line 25

def initialize(class_mapper)
  @class_mapper = class_mapper
end

Instance Attribute Details

#sourceObject (readonly)

Returns the value of attribute source.



19
20
21
# File 'lib/rocketamf/pure/deserializer.rb', line 19

def source
  @source
end

Instance Method Details

#deserialize(source) ⇒ Object

Raises:



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/rocketamf/pure/deserializer.rb', line 36

def deserialize(source)
  raise AMFError, 'no source to deserialize' if source.nil?

  @source = source.is_a?(StringIO) ? source : StringIO.new(source)

  requests = []

  incomplete_request = nil

  until @source.eof?
    begin
      @string_cache = []
      @object_cache = []
      @trait_cache  = []

      @position_request_read = @source.pos

      requests << amf3_deserialize
    rescue AMFErrorIncomplete => e
      @source.pos = @position_request_read

      incomplete_request = @source.read

      break
    end
  end

  {
      requests:           requests,
      incomplete_request: incomplete_request
  }
end

#read_objectObject



71
72
73
# File 'lib/rocketamf/pure/deserializer.rb', line 71

def read_object
  amf3_deserialize
end