Simple async websocket server, using redis as broker.
$ git clone https://github.com/AHAPX/websocket
$ cd websocket
$ pip install -r requirements.txt$ python websocket.py -c ~/websocket.cfgConfig has ini format, i.e.
[main]
host = localhost
port = 9998
debug = false
[redis]
host = localhost
port = 6379
db = 1
channel = ws-channel- config - path to config file
- host - host of websocket, default=localhost
- port - port of websocket, default=9999
- rhost - host of redis broker, default=locahost
- rport - port of redis broker, default=6379
- rdb - number of redis db, default=0
- rchannel - redis channel for subscription, default=ws-channel
- debug - debug mode
$ python -m unittestWebsocket server subscribes to channel and wait messages. Message must be valid JSON. It should consist keys:
- message - required, text or JSON
- tags - list of tags, if it exists, websocket will send message only for clients with any tag from list
Send "ping" and you will receive "pong", if connection is ok
When connection is established client should send its tags, i.e.
{
"tags": ["tag1", "tag2"],
}After that if server sends message to tag1, your client will receive it.