class Protocol::WebSocket::Framer
Public Class Methods
new(stream, frames = FRAMES)
click to toggle source
# File lib/protocol/websocket/framer.rb, line 45 def initialize(stream, frames = FRAMES) @stream = stream @frames = frames end
Public Instance Methods
close()
click to toggle source
# File lib/protocol/websocket/framer.rb, line 50 def close @stream.close end
flush()
click to toggle source
# File lib/protocol/websocket/framer.rb, line 54 def flush @stream.flush end
read_frame(maximum_frame_size = MAXIMUM_ALLOWED_FRAME_SIZE)
click to toggle source
# File lib/protocol/websocket/framer.rb, line 58 def read_frame(maximum_frame_size = MAXIMUM_ALLOWED_FRAME_SIZE) # Read the header: finished, opcode = read_header # Read the frame: klass = @frames[opcode] || Frame frame = klass.read(finished, opcode, @stream, maximum_frame_size) return frame end
read_header()
click to toggle source
# File lib/protocol/websocket/framer.rb, line 73 def read_header if buffer = @stream.read(1) return Frame.parse_header(buffer) end raise EOFError, "Could not read frame header!" end
write_frame(frame)
click to toggle source
# File lib/protocol/websocket/framer.rb, line 69 def write_frame(frame) frame.write(@stream) end