Class: Rakie::WebsocketBasicMessage
- Inherits:
-
Object
- Object
- Rakie::WebsocketBasicMessage
- Includes:
- Proto
- Defined in:
- lib/rakie/websocket_proto.rb
Direct Known Subclasses
Constant Summary collapse
- FLAG_FIN =
1 << 7
- OP_CONTINUE =
0x0- OP_TEXT =
0x1- OP_BIN =
0x2- OP_CLOSE =
0x8- OP_PING =
0x9- OP_PONG =
0xA- FLAG_MASK =
1 << 7
- PARSE_OPERATION =
PARSE_BEGIN- PARSE_LEN =
1- PARSE_EXT_LEN =
2- PARSE_MASKING =
3- PARSE_PAYLOAD =
4
Constants included from Proto
Instance Attribute Summary collapse
-
#fin ⇒ Object
writeonly
Sets the attribute fin.
-
#length ⇒ Object
Returns the value of attribute length.
-
#mask ⇒ Object
Returns the value of attribute mask.
-
#op_code ⇒ Object
Returns the value of attribute op_code.
-
#payload ⇒ Object
Returns the value of attribute payload.
Instance Method Summary collapse
- #deserialize(source) ⇒ Object
- #fin? ⇒ Boolean
-
#initialize ⇒ WebsocketBasicMessage
constructor
A new instance of WebsocketBasicMessage.
- #serialize ⇒ Object
Methods included from Proto
#parse, #parse_offset, #parse_offset=, #parse_state, #parse_state=, #parse_status, #to_s
Constructor Details
#initialize ⇒ WebsocketBasicMessage
Returns a new instance of WebsocketBasicMessage.
25 26 27 28 29 30 31 32 33 |
# File 'lib/rakie/websocket_proto.rb', line 25 def initialize @fin = false @op_code = 0x0 @mask = false @masking = [] @length = 0 @long_ext = false @payload = '' end |
Instance Attribute Details
#fin=(value) ⇒ Object (writeonly)
Sets the attribute fin
23 24 25 |
# File 'lib/rakie/websocket_proto.rb', line 23 def fin=(value) @fin = value end |
#length ⇒ Object
Returns the value of attribute length.
22 23 24 |
# File 'lib/rakie/websocket_proto.rb', line 22 def length @length end |
#mask ⇒ Object
Returns the value of attribute mask.
22 23 24 |
# File 'lib/rakie/websocket_proto.rb', line 22 def mask @mask end |
#op_code ⇒ Object
Returns the value of attribute op_code.
22 23 24 |
# File 'lib/rakie/websocket_proto.rb', line 22 def op_code @op_code end |
#payload ⇒ Object
Returns the value of attribute payload.
22 23 24 |
# File 'lib/rakie/websocket_proto.rb', line 22 def payload @payload end |
Instance Method Details
#deserialize(source) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/rakie/websocket_proto.rb', line 40 def deserialize(source) current_state = parse_state case current_state when PARSE_OPERATION return parse_source_operation(source) when PARSE_LEN return parse_source_len(source) when PARSE_EXT_LEN return parse_source_ext_len(source) when PARSE_MASKING return parse_source_masking(source) when PARSE_PAYLOAD return parse_source_payload(source) end end |
#fin? ⇒ Boolean
35 36 37 |
# File 'lib/rakie/websocket_proto.rb', line 35 def fin? @fin end |
#serialize ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/rakie/websocket_proto.rb', line 61 def serialize data = '' data += pack_source_operation data += pack_source_len if @mask data += pack_source_masking data += pack_source_masked_payload return data end data += @payload return data end |