https://github.com/geolffreym/pubsub-websocket
WebSocket PubSub Server
https://github.com/geolffreym/pubsub-websocket
Last synced: 2 months ago
JSON representation
WebSocket PubSub Server
- Host: GitHub
- URL: https://github.com/geolffreym/pubsub-websocket
- Owner: geolffreym
- Created: 2016-04-20T23:02:39.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-04-20T23:08:28.000Z (about 9 years ago)
- Last Synced: 2025-02-02T09:27:50.008Z (4 months ago)
- Language: Python
- Size: 13.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PubSub Websocket Server
A simple Python PubSub WebsocketRun the requirements.txt
`pip install -r requirements.txt`Run the server
`python server.py`###A simple websocket javascript client
```js
var jwt = 'token1234589$%KRT_MK';
var channels = ['my_channel','my_channel2']
//Token is needed to authenticate user
//Channels to suscribe
var _socket = new WebSocket(
'ws://127.0.0.1:9500?token=' + jwt + '&channels=' + JSON.stringify(channels)
);_socket.addEventListener('open', function () {
console.log('open')
_socket.send(
JSON.stringify({
"channel": "my_channel",
"message":{"content": "Hi", "my_name": "Clone Mena"}
})
);
});_socket.addEventListener('message', function (e) {
console.log(e)
});
```