Documentation for pulsar 0.9.2. For development docs, go here.
The code for this example is located in the examples.chat.manage
module.
This example is web-based chat application which exposes three different wsgi routers:
Router
to render the web pageWebSocket
with the Chat
handlerRouter
with the Rpc
handler
for exposing a JSON-RPC api.To run the server:
python manage.py
and open web browsers at http://localhost:8060
To send messages from the JSON RPC open a python shell and:
>>> from pulsar.apps import rpc
>>> p = rpc.JsonProxy('http://127.0.0.1:8060/rpc')
>>> p.message('Hi from rpc')
'OK'
This example uses the pulsar Publish/Subscribe handler to synchronise messages in a multiprocessing web server.
examples.chat.manage.
Chat
(pubsub, channel)[source]¶The websocket handler (WS
) managing the chat application.
pubsub
¶The publish/subscribe handler created by the wsgi
application in the WebChat.setup()
method.
examples.chat.manage.
Rpc
(pubsub, channel, **kwargs)[source]¶rpc_message
(request, message)¶Publish a message via JSON-RPC
examples.chat.manage.
WebChat
(server_name)[source]¶This is the wsgi application for this web-chat example.
setup
(environ)[source]¶Called once only to setup the WSGI application handler.
Check lazy wsgi handler section for further information.