Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sloev/wsrpc
RPC with Websockets, python and tornado
https://github.com/sloev/wsrpc
Last synced: about 1 month ago
JSON representation
RPC with Websockets, python and tornado
- Host: GitHub
- URL: https://github.com/sloev/wsrpc
- Owner: sloev
- License: mit
- Created: 2016-01-01T20:13:43.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-01-01T20:44:04.000Z (almost 9 years ago)
- Last Synced: 2024-10-20T04:26:25.650Z (2 months ago)
- Language: Python
- Homepage:
- Size: 10.7 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
## WsRPC - RPC with python, tornado and websockets
This project is an extract from a private repository, all history has been removed and domain specific context removed aswell.
### What?
This project demonstrates how an RPC thru Websockets can be constructed using Tornado Websocket handlers.
The demo project introduces a lookup dictionary with functions that get different dependencies injected.
The functions are attached to the lookup table by a decorator that also can be used at runtime.
This means that you can call:
```python
add_to_ws_lookup(my_new_function)
```and then a new RPCall will be available in the running Websocket. Connected Clients will not need to reconnect to see this.
####JSON format
The format is:
```javascript
{"instruction":"silly instruction", "args":"silly args", "callback_id":"34_callme"}
```**instruction** is the name of the function you call, directly the same as the func name in python.
**args** can really be anything
**callback_id** is a voluntary(i havent checked how volluntary :-) id that you can give in order to better differentiate when receiving the responses. Remember the Websocket is full-duplex.
##How to run
install dependencies (atm. only tornado):```bash
sudo pip install -r requirements.txt
```see tests for dox, and run them:
```bash
python -m tornado.testing discover tests
```##Copyright
Johannes Gårdsted Valbjørn 2016