Skip to content

Commit

Permalink
Improved documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Antoukh committed May 9, 2012
1 parent 12b1c5e commit 41f45fc
Showing 1 changed file with 63 additions and 4 deletions.
67 changes: 63 additions & 4 deletions README.rst
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ Define yor own simple handler on ``ws_handlers.py``::
def on_message(self, message): def on_message(self, message):
self.send(str(random.randint(1,100))) self.send(str(random.randint(1,100)))

Define sample routes on your settings:: Define sample routes on your settings::
DEFAULT_WS_HANDLERS = { DEFAULT_WS_HANDLERS = {
Expand Down Expand Up @@ -57,9 +55,70 @@ For a concrete example, see ``examples`` directory.
Handlers api reference. Handlers api reference.
----------------------- -----------------------


TODO The basic handler have three methods that can be overridden: ``on_message``, ``on_open`` and ``on_close``. The
first message is received by ``on_open`` method, if this method returns None or nothink (alias of ``return None``),
the same message is received by ``on_message``. If you do not need this behavior, return ``False`` or ``True`` on
``on_open`` method.

``on_close`` method is called on conection is closed, this method does not receive any message.

Interface of ``WebSockerHandler``::
class WebSocketHandler(object):
def on_open(self, message):
pass

def on_message(self, message):
pass

def on_close(self):
pass


Command line reference. Command line reference.
----------------------- -----------------------


TODO ``--push-socket``

Tells to django-ws server (tornado) to use other push socket instead of default. This
socket is used to send data to django handler interface.

**Default**: ``ipc:///tmp/ws_push``

``--sub-socket``

Tells to django-ws server (tornado) to use other sub socket instead of default. This
socket is used to receive response stream from django handlers.

**Default**: ``ipc:///tmp/ws_sub``

``--websocket-url``

With this parameter you can set distinct websocket url.

**Default**: ``/socket``

``--threaded``

With this parameter, tells to django handlers run in threaded mode. Every websocket connection
creates and mantains one thread.

``--gevent``

With this parameter, tells to django handlers run in greenlets. Every websocket connection
creates and mantains one greenlet. This is useful if you keep many open connections. But, it
should be noted that the connection to the database must be greensafe.

``--multiprocess``

Same as ``--threaded`` but this mantains one python process for each websocket connection.

**Note**: this is not implemented currently.


Todo:
-----

* More documentation.
* More tests
* Integration of TornadIO2 with same handlers.

0 comments on commit 41f45fc

Please sign in to comment.