Pakyow.orgv0.11

Message Handlers

Any incoming message from a client is routed to a message handler. The handler can then perform some action and send back a response message. For example, the call route handler that ships with Pakyow Realtime is implemented as a handler (source).

Messages must be sent in the following format:

{
  id: 'unique-message-id',
  action: 'some-action'
}

The message can contain any number of custom fields required by the handler.

Handlers are implemented as blocks that accept a message and return a response. The connection's session and a default response object are also passed to the message handler block. Here's a completely valid handler that performs no action:

Pakyow::Realtime::MessageHandler.register :'some-action' do |message, session, response|
  response
end
Google+