Class: WebSocket::Frame::Incoming
- Defined in:
- lib/websocket/frame/incoming.rb,
lib/websocket/frame/incoming/client.rb,
lib/websocket/frame/incoming/server.rb
Overview
You should NEVER use this class directly - use Client or Server subclasses instead, as they contain additional frame options(i.e. Client-side masking in draft 04)
Construct or parse incoming WebSocket Frame.
Defined Under Namespace
Instance Attribute Summary
Attributes inherited from Base
#data, #error, #type, #version
Instance Method Summary collapse
-
#<<(data) ⇒ Object
Add provided string as raw incoming frame.
-
#decoded? ⇒ Boolean
If data is still encoded after receiving then this is false.
-
#initialize(args = {}) ⇒ Incoming
constructor
A new instance of Incoming.
-
#next ⇒ WebSocket::Frame::Incoming
Return next complete frame.
-
#to_s ⇒ String
If decoded then this will return frame content.
Methods inherited from Base
#error?, #inspect, #support_type?, #supported_frames
Constructor Details
#initialize(args = {}) ⇒ Incoming
Returns a new instance of Incoming.
16 17 18 19 |
# File 'lib/websocket/frame/incoming.rb', line 16 def initialize(args = {}) @decoded = args[:decoded] || false super end |
Instance Method Details
#<<(data) ⇒ Object
Add provided string as raw incoming frame.
31 32 33 |
# File 'lib/websocket/frame/incoming.rb', line 31 def <<(data) @data << data end |
#decoded? ⇒ Boolean
If data is still encoded after receiving then this is false. After calling “next” you will receive another instance of incoming frame, but with data decoded - this function will return true and to_s will return frame content instead of raw data.
25 26 27 |
# File 'lib/websocket/frame/incoming.rb', line 25 def decoded? @decoded end |
#next ⇒ WebSocket::Frame::Incoming
Return next complete frame. This function will merge together splitted frames and return as combined content. Check #error if nil received to check for eventual parsing errors
39 40 41 |
# File 'lib/websocket/frame/incoming.rb', line 39 def next decode_frame unless decoded? end |
#to_s ⇒ String
If decoded then this will return frame content. Otherwise it will return raw frame.
45 46 47 |
# File 'lib/websocket/frame/incoming.rb', line 45 def to_s @data end |