class Mongrel2::WebSocket::ClientHandshake
The client (request) handshake for a WebSocket
opening handshake.
Public Class Methods
response_class()
click to toggle source
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 257 def self::response_class return Mongrel2::WebSocket::ServerHandshake end
Public Instance Methods
protocols()
click to toggle source
The list of protocols in the handshake's Sec-WebSocket-Protocol header as an Array of Strings.
# File lib/mongrel2/websocket.rb, line 268 def protocols return ( self.headers.sec_websocket_protocol || '' ).split( /\s*,\s*/ ) end
response( protocol=nil )
click to toggle source
Create a Mongrel2::WebSocket::Handshake that will respond to the same server/connection as the receiver.
Calls superclass method
Mongrel2::Request#response
# File lib/mongrel2/websocket.rb, line 275 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