Class: WebSocketClient::FrameReader
- Inherits:
-
Object
- Object
- WebSocketClient::FrameReader
- Defined in:
- lib/websocket_client/frame_io.rb
Instance Attribute Summary collapse
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #eof? ⇒ Boolean
-
#initialize(source, debug = true) ⇒ FrameReader
constructor
A new instance of FrameReader.
- #read_frame ⇒ Object
Constructor Details
#initialize(source, debug = true) ⇒ FrameReader
Returns a new instance of FrameReader.
71 72 73 74 |
# File 'lib/websocket_client/frame_io.rb', line 71 def initialize(source,debug=true) @source = source @debug = debug end |
Instance Attribute Details
#debug ⇒ Object
Returns the value of attribute debug.
69 70 71 |
# File 'lib/websocket_client/frame_io.rb', line 69 def debug @debug end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
68 69 70 |
# File 'lib/websocket_client/frame_io.rb', line 68 def source @source end |
Instance Method Details
#eof? ⇒ Boolean
76 77 78 |
# File 'lib/websocket_client/frame_io.rb', line 76 def eof? @source.eof? end |
#read_frame ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/websocket_client/frame_io.rb', line 80 def read_frame() buffer = nil state = :none while ( ! source.eof? ) b = source.getbyte case ( b ) when 0x00 if ( state == :half_closed ) return CloseFrame::INSTANCE end buffer = '' when 0xFF if ( ! buffer.nil? ) return TextFrame.new( buffer ) else state = :half_closed end else buffer << b end end nil end |