Class: WebSocket::Protocol::Draft76

Inherits:
Draft75 show all
Defined in:
lib/websocket/protocol/draft76.rb

Constant Summary collapse

HEAD_SIZE =
8

Constants inherited from WebSocket::Protocol

STATES

Instance Attribute Summary

Attributes inherited from WebSocket::Protocol

#protocol, #ready_state

Instance Method Summary collapse

Methods inherited from Draft75

#frame, #parse

Methods inherited from WebSocket::Protocol

#binary, jruby?, #onclose, #onerror, #onmessage, #onopen, #ping, rbx?, #state, #text

Constructor Details

#initialize(socket, options = {}) ⇒ Draft76

Returns a new instance of Draft76.



7
8
9
10
11
12
# File 'lib/websocket/protocol/draft76.rb', line 7

def initialize(socket, options = {})
  super
  input  = @socket.env['rack.input']
  @stage = -1
  @head  = input ? input.read.bytes.to_a : []
end

Instance Method Details

#close(reason = nil, code = nil) ⇒ Object



24
25
26
27
28
29
# File 'lib/websocket/protocol/draft76.rb', line 24

def close(reason = nil, code = nil)
  return false if @ready_state == 3
  @socket.write("\xFF\x00")
  @ready_state = 3
  dispatch(:onclose, CloseEvent.new(nil, nil))
end

#startObject



18
19
20
21
22
# File 'lib/websocket/protocol/draft76.rb', line 18

def start
  return false unless super
  send_handshake_body
  true
end

#versionObject



14
15
16
# File 'lib/websocket/protocol/draft76.rb', line 14

def version
  'hixie-76'
end