Class: WebSocketRb::Wrapper::FrameBase
- Inherits:
-
Object
- Object
- WebSocketRb::Wrapper::FrameBase
- Defined in:
- lib/web_socket_rb/wrapper/frame_base.rb
Overview
Class defines base frame structure.
Direct Known Subclasses
Constant Summary collapse
- CONTINUATION =
Constants represents type of frame
0x0.to_i
- TEXT =
0x1.to_i
- BINARY =
0x2.to_i
- CLOSE =
0x8.to_i
- PING =
0x9.to_i
- PONG =
0xA.to_i
Instance Attribute Summary collapse
-
#fin ⇒ Object
Returns the value of attribute fin.
-
#mask ⇒ Object
Returns the value of attribute mask.
-
#masking_key ⇒ Object
Returns the value of attribute masking_key.
-
#opcode ⇒ Object
Returns the value of attribute opcode.
-
#payload_data ⇒ Object
Returns the value of attribute payload_data.
-
#payload_len ⇒ Object
Returns the value of attribute payload_len.
-
#rsv1 ⇒ Object
Returns the value of attribute rsv1.
-
#rsv2 ⇒ Object
Returns the value of attribute rsv2.
-
#rsv3 ⇒ Object
Returns the value of attribute rsv3.
Instance Method Summary collapse
-
#destination ⇒ Object
Read destination from payload data.
-
#message ⇒ Object
Read message from payload data.
-
#to_bytes ⇒ Object
Method converts frame to bytes representation.
Instance Attribute Details
#fin ⇒ Object
Returns the value of attribute fin.
13 14 15 |
# File 'lib/web_socket_rb/wrapper/frame_base.rb', line 13 def fin @fin end |
#mask ⇒ Object
Returns the value of attribute mask.
13 14 15 |
# File 'lib/web_socket_rb/wrapper/frame_base.rb', line 13 def mask @mask end |
#masking_key ⇒ Object
Returns the value of attribute masking_key.
13 14 15 |
# File 'lib/web_socket_rb/wrapper/frame_base.rb', line 13 def masking_key @masking_key end |
#opcode ⇒ Object
Returns the value of attribute opcode.
13 14 15 |
# File 'lib/web_socket_rb/wrapper/frame_base.rb', line 13 def opcode @opcode end |
#payload_data ⇒ Object
Returns the value of attribute payload_data.
13 14 15 |
# File 'lib/web_socket_rb/wrapper/frame_base.rb', line 13 def payload_data @payload_data end |
#payload_len ⇒ Object
Returns the value of attribute payload_len.
13 14 15 |
# File 'lib/web_socket_rb/wrapper/frame_base.rb', line 13 def payload_len @payload_len end |
#rsv1 ⇒ Object
Returns the value of attribute rsv1.
13 14 15 |
# File 'lib/web_socket_rb/wrapper/frame_base.rb', line 13 def rsv1 @rsv1 end |
#rsv2 ⇒ Object
Returns the value of attribute rsv2.
13 14 15 |
# File 'lib/web_socket_rb/wrapper/frame_base.rb', line 13 def rsv2 @rsv2 end |
#rsv3 ⇒ Object
Returns the value of attribute rsv3.
13 14 15 |
# File 'lib/web_socket_rb/wrapper/frame_base.rb', line 13 def rsv3 @rsv3 end |
Instance Method Details
#destination ⇒ Object
Read destination from payload data
35 36 37 38 |
# File 'lib/web_socket_rb/wrapper/frame_base.rb', line 35 def destination json_payload_data = JSON.parse(payload_data) json_payload_data.is_a?(Hash) ? json_payload_data['destination'] : nil end |
#message ⇒ Object
Read message from payload data
41 42 43 44 |
# File 'lib/web_socket_rb/wrapper/frame_base.rb', line 41 def json_payload_data = JSON.parse(payload_data) json_payload_data.is_a?(Hash) ? json_payload_data['message'] : nil end |
#to_bytes ⇒ Object
Method converts frame to bytes representation.
17 18 19 20 21 22 23 24 25 |
# File 'lib/web_socket_rb/wrapper/frame_base.rb', line 17 def to_bytes bytes = '' bytes << fin_rsv_opcode_to_byte bytes << mask_payload_length_to_byte bytes << ext_payload_len_to_byte bytes << masking_key_to_byte bytes << payload_data_to_byte bytes end |