Class: Protocol::WebSocket::Extension::Compression::Inflate
- Inherits:
-
Object
- Object
- Protocol::WebSocket::Extension::Compression::Inflate
- Defined in:
- lib/protocol/websocket/extension/compression/inflate.rb
Constant Summary collapse
- TRAILER =
[0x00, 0x00, 0xff, 0xff].pack('C*')
Instance Attribute Summary collapse
-
#context_takeover ⇒ Object
readonly
Returns the value of attribute context_takeover.
-
#window_bits ⇒ Object
readonly
Returns the value of attribute window_bits.
Class Method Summary collapse
-
.client(parent, server_max_window_bits: 15, server_no_context_takeover: false, **options) ⇒ Object
Client reading from server.
-
.server(parent, client_max_window_bits: 15, client_no_context_takeover: false, **options) ⇒ Object
Server reading from client.
Instance Method Summary collapse
-
#initialize(parent, context_takeover: true, window_bits: 15) ⇒ Inflate
constructor
A new instance of Inflate.
- #to_s ⇒ Object
- #unpack_frames(frames, **options) ⇒ Object
Constructor Details
#initialize(parent, context_takeover: true, window_bits: 15) ⇒ Inflate
Returns a new instance of Inflate.
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/protocol/websocket/extension/compression/inflate.rb', line 31 def initialize(parent, context_takeover: true, window_bits: 15) @parent = parent @inflate = nil # This is handled during negotiation: # if window_bits < MINIMUM_WINDOW_BITS # window_bits = MINIMUM_WINDOW_BITS # end @window_bits = window_bits @context_takeover = context_takeover end |
Instance Attribute Details
#context_takeover ⇒ Object (readonly)
Returns the value of attribute context_takeover.
50 51 52 |
# File 'lib/protocol/websocket/extension/compression/inflate.rb', line 50 def context_takeover @context_takeover end |
#window_bits ⇒ Object (readonly)
Returns the value of attribute window_bits.
49 50 51 |
# File 'lib/protocol/websocket/extension/compression/inflate.rb', line 49 def window_bits @window_bits end |
Class Method Details
.client(parent, server_max_window_bits: 15, server_no_context_takeover: false, **options) ⇒ Object
Client reading from server.
14 15 16 17 18 19 |
# File 'lib/protocol/websocket/extension/compression/inflate.rb', line 14 def self.client(parent, server_max_window_bits: 15, server_no_context_takeover: false, **) self.new(parent, window_bits: server_max_window_bits, context_takeover: !server_no_context_takeover, ) end |
.server(parent, client_max_window_bits: 15, client_no_context_takeover: false, **options) ⇒ Object
Server reading from client.
22 23 24 25 26 27 |
# File 'lib/protocol/websocket/extension/compression/inflate.rb', line 22 def self.server(parent, client_max_window_bits: 15, client_no_context_takeover: false, **) self.new(parent, window_bits: client_max_window_bits, context_takeover: !client_no_context_takeover, ) end |
Instance Method Details
#to_s ⇒ Object
45 46 47 |
# File 'lib/protocol/websocket/extension/compression/inflate.rb', line 45 def to_s "#<#{self.class} window_bits=#{@window_bits} context_takeover=#{@context_takeover}>" end |
#unpack_frames(frames, **options) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/protocol/websocket/extension/compression/inflate.rb', line 52 def unpack_frames(frames, **) buffer = @parent.unpack_frames(frames, **) frame = frames.first if frame.flag?(Frame::RSV1) buffer = self.inflate(buffer) frame.flags &= ~Frame::RSV1 end return buffer end |