Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rvmoldova/live-front-ws-module
Module what links to WS api
https://github.com/rvmoldova/live-front-ws-module
Last synced: 5 days ago
JSON representation
Module what links to WS api
- Host: GitHub
- URL: https://github.com/rvmoldova/live-front-ws-module
- Owner: rvmoldova
- Created: 2016-02-04T18:07:46.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-02-08T16:37:07.000Z (almost 9 years ago)
- Last Synced: 2024-10-10T05:36:01.986Z (about 1 month ago)
- Language: JavaScript
- Size: 9.77 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Module to connect to WS api
##### Just install it via Bower
```
bower install --save live-front-ws-module
```I made this plugin for one of my projects.
To init it:
```
var LM = new LiveModule('ws://localhost:1235', {
debug: false, // VERBOSE
reconnect: true, // On fail, try to reconnect each second,
onDisconnectCallback: function(rs) { // callbacks
console.log(rs)
},
onConnectCallback: function(rs) { // callbacks
console.log(rs)
},
onErrorCallback: function(rs) { // callbacks
console.log(rs)
}
});
```And other examples:
```
LM.connect(); // connect to websocket;LM.auth('token'); // auths with token;
LM.subscribe('chat', function(rs) { // subscribe to channel chat
console.log('Receive from channel chat', rs)
});LM.unsubscribe('chat'); // unsubscribe to channel chat
```