class Rakie::WebsocketBasicMessage

Constants

FLAG_FIN
FLAG_MASK
OP_BIN
OP_CLOSE
OP_CONTINUE
OP_PING
OP_PONG
OP_TEXT
PARSE_EXT_LEN
PARSE_LEN
PARSE_MASKING
PARSE_OPERATION
PARSE_PAYLOAD

Attributes

fin[W]
length[RW]
mask[RW]
op_code[RW]
payload[RW]

Public Class Methods

new() click to toggle source
# 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

Public Instance Methods

deserialize(source) click to toggle source

@param [String] source

# 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?() click to toggle source
# File lib/rakie/websocket_proto.rb, line 35
def fin?
  @fin
end
serialize() click to toggle source
# 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