Mongrel2::WebSocket::

ClientHandshake

class
Superclass
Mongrel2::HTTPRequest

The client (request) handshake for a WebSocket opening handshake.

Public Class Methods

anchor
response_class()

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

Public Instance Methods

anchor
protocols()

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
anchor
response( protocol=nil )

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