The Mongrel2 WebSocket namespace module. Contains constants and classes for building WebSocket services.
class WebSocketEchoServer
def handle_websocket_handshake( handshake )
# :TODO: Sub-protocol/protocol version checks?
return handshake.response
end
def handle_websocket( frame )
# Close connections that send invalid frames
if !frame.valid?
res = frame.response( :close )
res.set_close_status( WebSocket::CLOSE_PROTOCOL_ERROR )
return res
end
# Do something with the frame
...
end
end