Class: Lumberjack::AckingProtocolV1

Inherits:
Object
  • Object
show all
Defined in:
lib/lumberjack/server.rb

Overview

class Connection

Instance Method Summary collapse

Constructor Details

#initialize(window_size) ⇒ AckingProtocolV1

Returns a new instance of AckingProtocolV1.


386
387
388
389
# File 'lib/lumberjack/server.rb', line 386

def initialize(window_size)
  @next_ack = nil
  @window_size = window_size
end

Instance Method Details

#ack?(sequence) ⇒ Boolean

Returns:

  • (Boolean)

391
392
393
394
395
396
# File 'lib/lumberjack/server.rb', line 391

def ack?(sequence)
  # The first encoded event will contain the sequence number 
  # this is needed to know when we should ack.
  @next_ack = compute_next_ack(sequence) if @next_ack.nil?
  sequence == @next_ack
end

#ack_frame(sequence) ⇒ Object


398
399
400
# File 'lib/lumberjack/server.rb', line 398

def ack_frame(sequence)
  ["1A", sequence].pack("A*N")
end