class WebSocket::Frame::Handler::Handler03
Constants
- FRAME_TYPES
Hash of frame names and it's opcodes
- FRAME_TYPES_INVERSE
Hash of frame opcodes and it's names
Public Instance Methods
decode_frame()
click to toggle source
@see WebSocket::Frame::Handler::Base#decode_frame
# File lib/websocket/frame/handler/handler03.rb, line 41 def decode_frame while @frame.data.size > 1 valid_header, more, frame_type, mask, payload_length = decode_header return unless valid_header application_data = decode_payload(payload_length, mask) if more decode_continuation_frame(application_data, frame_type) elsif frame_type == :continuation return decode_finish_continuation_frame(application_data) else raise(WebSocket::Error::Frame::InvalidPayloadEncoding) if frame_type == :text && !application_data.valid_encoding? return @frame.class.new(version: @frame.version, type: frame_type, data: application_data, decoded: true) end end nil end
encode_frame()
click to toggle source
@see WebSocket::Frame::Handler::Base#encode_frame
# File lib/websocket/frame/handler/handler03.rb, line 27 def encode_frame frame = if @frame.outgoing_masking? masking_key = SecureRandom.random_bytes(4) tmp_data = Data.new(masking_key + @frame.data) tmp_data.set_mask masking_key + tmp_data.getbytes(4, tmp_data.size) else @frame.data end encode_header + frame end
masking?()
click to toggle source
Allow turning on or off masking
# File lib/websocket/frame/handler/handler03.rb, line 61 def masking? false end
supported_frames()
click to toggle source
@see WebSocket::Frame::Base#supported_frames
# File lib/websocket/frame/handler/handler03.rb, line 22 def supported_frames %i[text binary close ping pong] end