examples/ws-echo.rb in mongrel2-0.26.0 vs examples/ws-echo.rb in mongrel2-0.27.0
- old
+ new
@@ -84,9 +84,21 @@
self.conn.reply_close( request )
return nil
end
+ # Handle the initial handshake. Assumes no sub-protocols or protocol version
+ # checks are necessary.
+ def handle_websocket_handshake( handshake )
+ self.log.info "Handshake from %s" % [ handshake.remote_ip ]
+
+ response = handshake.response( handshake.protocols.first )
+ @connections[ [handshake.sender_id, handshake.conn_id] ] = Time.now
+
+ return response
+ end
+
+
# This is the main handler for WebSocket requests. Each frame comes in as a
# Mongrel::WebSocket::Frame object, and then is dispatched according to what
# opcode it has.
def handle_websocket( frame )