Class: SocketClientWithPolicy

Inherits:
Object
  • Object
show all
Defined in:
lib/mrpin/core/remote/socket/with_policy/socket_client_with_policy.rb

Instance Method Summary collapse

Constructor Details

#initializeSocketClientWithPolicy

Returns a new instance of SocketClientWithPolicy.



12
13
14
15
16
# File 'lib/mrpin/core/remote/socket/with_policy/socket_client_with_policy.rb', line 12

def initialize
  @policy_was_sent = false

  @policy_regexp = '<policy_request_stub>'
end

Instance Method Details

#get_requestsObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/mrpin/core/remote/socket/with_policy/socket_client_with_policy.rb', line 19

def get_requests
  result = []

  return result unless @is_online

  @requests_locker.synchronize do
    begin

      unless @data_buffer.empty?

        deserialize_data = AMF::Root.deserialize(@data_buffer)
        result           = deserialize_data[:objects]
        @data_buffer     = deserialize_data[:incomplete_objects] || ''

        if result.empty?
          try_send_policy
        elsif !@policy_was_sent
          @policy_was_sent = true
        end
      end

    rescue Exception => e
      on_get_requests_error(e)
    end #begin/rescue
  end #synchronize

  result
end