Welcome to filtered_websocket’s documentation!¶

Filtered WebSocket is a straight forward server framework which allows you to compose complex behaviors without using callbacks or subclassing any protocols. It also features redis integration for remote storage and message passing via pubsub.

Install¶ pip install filtered_websocket or git clone https://github.com/mrrrgn/filtered_websocket && cd filtered_websocket && python setup.py install

Getting Started¶ After installing filtered_websocket you’ll have access to the server launcher via fws_server . Running fws_server -h will give you a list of configuration options while simply running fws_server will start a server running the default broadcast_messages and stdout_messages modules on port 9000. filtered_websocket is bundled with several useful modules which may be attached to a server via the ‘-f’ option like so: # This will start a server which prints rawdata and broadcasts messages to users who have set a "token" $ fws_server -f filtered_websocket.filters.stdout_rawdata filtered_websocket.filters.broadcast_messages_by_token

Using Redis¶ Redis integration is activated by setting an environment variable STORAGE_OBJECT_MODULE to filtered_websocket.storage_objects.redis . When the redis storage object is activated fws_server -h will display new argument options for configuring your redis instance connection and channel subscriptions. The following would start a server which broadcasts messages received from a redis channel named global to all connected clients: $ export STORAGE_OBJECT_MODULE="filtered_websocket.storage_objects.redis" $ fws_server -f filtered_websocket.filters.broadcast_pubsub This message, published via a redis client, connected to the same redis instance, would be sent to all connected WebSocket clients: >>> import redis >>> r = redis . Redis () # connections to localhost on default port >>> r . publish ( "global" , "hello from the server!" ) # Connected WebSocket clients receive this message To start a server which broadcasts messages both between clients and from remote, server side, processes to clients: $ export STORAGE_OBJECT_MODULE="filtered_websocket.storage_objects.redis" $ fws_server -f filtered_websocket.filters.broadcast_messages filtered_websocket.filters.broadcast_pubsub