Skip to content

Commit

Permalink
Update README.rst
Browse files Browse the repository at this point in the history
  • Loading branch information
Abdeljelil committed Aug 6, 2016
1 parent 7b9db68 commit c9a61f0
Showing 1 changed file with 72 additions and 4 deletions.
76 changes: 72 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,80 @@ Websocket_redis
``websocket_redis`` is an asynchronous python module gather two projects `websockets <https://github.com/aaugustin/websockets>`_ and `aioredis <https://github.com/aio-libs/aioredis>`_ to make the communication between the client and backend as easy as possible without losing any message has been sent from the client.

Installation
----------------
`pip install websocket_redis`
------------
.. code:: shell
`pip install websocket_redis`

`pypi <https://pypi.python.org/pypi/websocket_redis>`_.

Usage
-----
Usage examples
--------------

Override WSHandler Methodes:

.. code:: python
import asyncio
from websocket_redis.server.ws_server import WSServer
from websocket_redis.server.ws_handler import WSHandler
class MyWSHandler(WSHandler):
@asyncio.coroutine
def on_close(self, code):
print("Session {} has closed, client : {}".format(
self.session_id, self.client))
@asyncio.coroutine
def on_error(self, e):
print("Exception {} has raised, client : {}".format(
e, self.client))
@asyncio.coroutine
def on_message(self, text):
print("Message \'{}\' has received from client : {}".format(
text, self.client))
@asyncio.coroutine
def on_send(self, text):
print("Message \'{}\' will be sent to {}".format(
text, self.client))
Start Websocker server:

.. code:: python
ws_connection = dict(
host="127.0.0.1",
port=5678)
redis_connection = dict(
address=("localhost", 6379)
)
loop = asyncio.get_event_loop()
server = WSServer(
ws_connection=ws_connection,
redis_connection=redis_connection,
app_name="test_app",
ws_handler_class=MyWSHandler
)
try:
loop.run_until_complete(server.run())
loop.run_forever()
except KeyboardInterrupt:
server.close()
loop.close()
Start Websocker server:

.. code:: python
TODO:

.. |versions| image:: https://img.shields.io/pypi/pyversions/websokcer_redis.svg
Expand Down

0 comments on commit c9a61f0

Please sign in to comment.