The client (request) handshake for a WebSocket
opening handshake.
Override the type of response returned by this request type. Since websocket handshakes are symmetrical, responses are just new Mongrel2::WebSocket::Handshakes with the same Mongrel2
sender and connection IDs.
# File lib/mongrel2/websocket.rb, line 232
def self::response_class
return Mongrel2::WebSocket::ServerHandshake
end
The list of protocols in the handshake's Sec-WebSocket-Protocol header as an Array of Strings.
# File lib/mongrel2/websocket.rb, line 243
def protocols
return ( self.headers.sec_websocket_protocol || '' ).split( /\s*,\s*/ )
end
Create a Mongrel2::WebSocket::Handshake that will respond to the same server/connection as the receiver.
# File lib/mongrel2/websocket.rb, line 250
def response( protocol=nil )
@response = super() unless @response
if protocol
raise Mongrel2::WebSocket::HandshakeError,
"attempt to create a %s handshake which isn't supported by the client." %
[ protocol ] unless self.protocols.include?( protocol.to_s )
@response.protocols = protocol
end
return @response
end