Class: PollApi

Inherits:
Object
  • Object
show all
Defined in:
lib/linerb/api/pollApi.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ PollApi

Returns a new instance of PollApi.



6
7
8
# File 'lib/linerb/api/pollApi.rb', line 6

def initialize(client)
  @client = client
end

Instance Method Details

#api_fetch_operationsObject



10
11
12
13
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
43
# File 'lib/linerb/api/pollApi.rb', line 10

def api_fetch_operations
  recv = PollRecv.new

  rev = @client.getLastOpRevision()

  @local_rev = rev

  last_rev = rev

  while true do
    begin
      operations = @client.fetchOperations(@local_rev, 50)

      operations.each { |op|

        if op::type == P0_a_e_a_b_od::END_OF_OPERATION || op::type == P0_a_e_a_b_od::DUMMY
          next
        end

        @local_rev = op::revision

        if last_rev < op::revision
          last_rev = op::revision
          Async do
            recv.op_process(op)
          end
        end
      }

    rescue Net::ReadTimeout
      retry
    end
  end
end