class Mongrel2::WebSocket::Response

WebSocket response – this is the container for Frames sent to a client.

Public Class Methods

from_request( request ) click to toggle source

Return a response to the specified request, inferring appropriate flags if appropriate.

Calls superclass method Mongrel2::Response::from_request
# File lib/mongrel2/websocket.rb, line 385
def self::from_request( request )
        response = super

        if request.opcode == :ping
                response.opcode = :pong
                IO.copy_stream( request.payload, response.payload, 4096 )
        else
                # Numeric in case it's a custom (reserved) value
                response.opcode = request.numeric_opcode
        end

        return response
end
new( sender_id, conn_id, body='' ) click to toggle source

Init a few instance variables unique to websocket requests/responses.

Calls superclass method Mongrel2::Response::new
# File lib/mongrel2/websocket.rb, line 401
def initialize( sender_id, conn_id, body='' )
        @frame = Mongrel2::WebSocket::Frame.new( body )
        super( sender_id, conn_id, @frame.payload )
end

Public Instance Methods

frame() click to toggle source

Delegate some methods to the contained frame

# File lib/mongrel2/websocket.rb, line 409
def_instance_delegators :frame,
        :puts, :to_s, :each_chunk, :<<, :make_close_frame, :set_status