Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zaach/node-simplepush
https://github.com/zaach/node-simplepush
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/zaach/node-simplepush
- Owner: zaach
- Created: 2013-04-15T21:32:54.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-03-06T22:45:49.000Z (almost 10 years ago)
- Last Synced: 2024-04-16T00:26:35.297Z (8 months ago)
- Language: JavaScript
- Size: 131 KB
- Stars: 5
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
node-simplepush
====
A node implementation of the [SimplePush protocol](https://wiki.mozilla.org/WebAPI/SimplePush/Protocol).Install
====You'll need node.js and npm installed first.
To install from github:
git clone http://github.com/zaach/node-simplepush
cd ./node-simplepush
npm installIf you want persistant storage, you'll need redis installed on your system also.
Run
====
To start the SimplePush server, run:node ./bin/simplepush
To run the examples, start the AppServer:
node examples/appserver.js
Then run the client:
node examples/client.js
Client API
====### var client = new SimplePUshClient(options)
Options may include:
* `pushServer`: the WebSocket URL of the SimplePush server the client should connect to
* `uaid`: a unique UserAgent ID. Defaults to a random uuid (version 4).### client.init(cb)
Arguments:* `cb`: fired once the client connects and completes the handshake
### client.register(cb)
Arguments:* `cb`: callback called with three arguments:
* An error if any, or null
* A response object with `channelID` and `pushEndpoint` keys
* A channel object that can receive push notifications. Attach a `push` event handler to the channel object to receive the notifications. E.g.```
client.register(function(err, reply, channel) {
console.log('Channel ID', reply.channelID);
console.log('Endpoint: ', reply.pushEndpoint);channel.on('push', function(err, update) {
console.log('Reveived update:', update.version);
});
});
```### client.unregister(channelID, cb)
Arguments:* `channelID`: The channel to unregister
* `cb`: callback when unregistration completes