Strelka::WebSocketServer::

Routing

module
Included Modules
Strelka::Constants
Mongrel2::WebSocket::Constants
Extended With
Loggability
Strelka::Plugin

Frame routing logic for Strelka WebSocketServers.

For a protocol that defines its own opcodes:

class ChatServer
    plugin :routing

    opcodes :nick => 7,
            :emote => 8

    on_text do |frame|
        # ...
    end

    on_nick do |frame|
        self.set_nick( frame.socket_id, frame.payload.read )
    end

Public Instance Methods

anchor
handle_frame( frame )

Dispatch the incoming frame to its handler based on its opcode

# File lib/strelka/websocketserver/routing.rb, line 104
def handle_frame( frame )
        self.log.debug "[:routing] Opcode map is: %p" % [ self.class.opcode_map ]
        opname = self.class.opcode_map[ frame.numeric_opcode ]
        self.log.debug "[:routing] Routing frame: %p" % [ opname ]

        handler = self.class.op_callbacks[ opname ] or return super

        return handler.bind( self ).call( frame )
end