https://github.com/averagemarcus/pusher-websocket-espruino
A simple Pusher client for use on the Espruino
https://github.com/averagemarcus/pusher-websocket-espruino
Last synced: over 1 year ago
JSON representation
A simple Pusher client for use on the Espruino
- Host: GitHub
- URL: https://github.com/averagemarcus/pusher-websocket-espruino
- Owner: AverageMarcus
- Created: 2016-09-20T08:50:12.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-09-21T07:53:01.000Z (almost 10 years ago)
- Last Synced: 2025-02-12T11:24:18.607Z (over 1 year ago)
- Language: JavaScript
- Size: 7.81 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# pusher-websocket-espruino
A simple Pusher client for use on the Espruino
## :warning: Currently a work in progress :warning:
## Example
```js
var PUSHER_KEY = '...';
new Pusher(PUSHER_KEY, {}, function(pusher) {
var testChannel = pusher.subscribe('test_channel');
testChannel.bind('my_event', function(data) {
console.log('Got a message:', data);
});
});
```
## API
### Constructor
`Pusher(appKey, options, callback)`
Returns: [Pusher](#pusher)
Options (with defaults):
```
{
cluster: 'eu', // (optional)
encrypted: false // (optional) - NOT YET IMPLEMENTED
}
```
Callback:
```
function(pusher) { ... }
```
### Pusher
#### subscribe
```
pusher.subscribe(channelName, options);
```
Returns: [Channel](#channel)
#### unsubscribe
```
pusher.unsubscribe(channelName);
```
#### bind
```
pusher.bind(EVENT, callback);
```
#### disconnect
```
pusher.disconnect();
```
### Channel
### bind
```
channel.bind(eventName, callback);
```
### trigger
```
channel.trigger(eventName, data);
```
### unsubscribe
```
channel.unsubscribe();
```