Module: Plum::FlowControl

Included in:
Connection, Stream
Defined in:
lib/plum/flow_control.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#recv_remaining_windowObject (readonly)

Returns the value of attribute recv_remaining_window


6
7
8
# File 'lib/plum/flow_control.rb', line 6

def recv_remaining_window
  @recv_remaining_window
end

#send_remaining_windowObject (readonly)

Returns the value of attribute send_remaining_window


6
7
8
# File 'lib/plum/flow_control.rb', line 6

def send_remaining_window
  @send_remaining_window
end

Instance Method Details

#send(frame) ⇒ Object

Sends frame respecting inner-stream flow control.

Parameters:

  • frame (Frame)

    The frame to be sent.


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/plum/flow_control.rb', line 10

def send(frame)
  if frame.type == :data
    @send_buffer << frame
    if @send_remaining_window < frame.length
      if Stream === self
        connection.callback(:send_deferred, self, frame)
      else
        callback(:send_deferred, self, frame)
      end
    else
      consume_send_buffer
    end
  else
    send_immediately frame
  end
end

#window_update(wsi) ⇒ Object

Increases receiving window size. Sends WINDOW_UPDATE frame to the peer.

Parameters:

  • wsi (Integer)

    The amount to increase receiving window size. The legal range is 1 to 2^32-1.


29
30
31
32
33
34
# File 'lib/plum/flow_control.rb', line 29

def window_update(wsi)
  @recv_remaining_window += wsi
  payload = String.new.push_uint32(wsi)
  sid = (Stream === self) ? self.id : 0
  send_immediately Frame.new(type: :window_update, stream_id: sid, payload: payload)
end