Class: WebSocketRb::Wrapper::FrameOutgoing

Inherits:
FrameBase
  • Object
show all
Defined in:
lib/web_socket_rb/wrapper/frame_outgoing.rb

Direct Known Subclasses

FrameClose, FramePing, FramePong, FrameText

Constant Summary

Constants inherited from FrameBase

WebSocketRb::Wrapper::FrameBase::BINARY, WebSocketRb::Wrapper::FrameBase::CLOSE, WebSocketRb::Wrapper::FrameBase::CONTINUATION, WebSocketRb::Wrapper::FrameBase::PING, WebSocketRb::Wrapper::FrameBase::PONG, WebSocketRb::Wrapper::FrameBase::TEXT

Instance Attribute Summary

Attributes inherited from FrameBase

#fin, #mask, #masking_key, #opcode, #payload_data, #payload_len, #rsv1, #rsv2, #rsv3

Instance Method Summary collapse

Methods inherited from FrameBase

#destination, #message, #to_bytes

Constructor Details

#initialize(options = {}) ⇒ FrameOutgoing

Returns a new instance of FrameOutgoing.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/web_socket_rb/wrapper/frame_outgoing.rb', line 7

def initialize(options = {})
  @payload_data = options.fetch(:payload_data, '')
  @payload_len  = @payload_data.bytes.size
  @fin          = options.fetch(:fin, true)
  @rsv1         = options.fetch(:rsv1, false) # No externals (false by default)
  @rsv2         = options.fetch(:rsv2, false) # No externals (false by default)
  @rsv3         = options.fetch(:rsv3, false) # No externals (false by default)
  @opcode       = options.fetch(:opcode, CONTINUATION) # Type of frame (continuation by default)
  @mask         = options.fetch(:mask, false) # Mask (false by default)
  @masking_key  = Random.new.bytes(4) if @mask # Generate random masking key if mask
end