Module: PalavaMachine::Server::VerifyHandshake

Defined in:
lib/palava_machine/server/verify_handshake.rb

Instance Method Summary collapse

Instance Method Details

#verify_handshake(handshake) ⇒ Object



15
16
17
18
19
20
# File 'lib/palava_machine/server/verify_handshake.rb', line 15

def verify_handshake(handshake)
  # Other: Access properties on the EM::WebSocket::Handshake object, e.g. path, query_string, origin, headers
  if handshake.headers['Sec-WebSocket-Protocol'] != PalavaMachine.protocol_identifier
    raise HandshakeError, "incompatible sub-protocol: #{ handshake.headers['Sec-WebSocket-Protocol'] }"
  end
end

#ws_open(ws, handshake) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/palava_machine/server/verify_handshake.rb', line 6

def ws_open(ws, handshake)
  verify_handshake(handshake)
  super(ws, handshake)
rescue HandshakeError => e
  manager.error "HandshakeError for #{ws.hash}\n#{e.inspect}"
  send_error(ws, e)
  ws.close 4242
end