Official Scaledrone Node.js pushing library
Allows for usage of all Scaledrone's REST API methods.
For the Node.js WebSocket API Client check out this link.
npm install scaledrone-node-push --save
Create a new instance of Scaledrone passing it the channelId
and secretKey
that you can find from the channel's page
const Scaledrone = require('scaledrone-node-push');
const sd = new Scaledrone({
channelId: 'CHANNEL_ID',
secretKey: 'SECRET_KEY'
});
const message = {foo: 'bar'};
const room = 'notifications';
sd.publish(room, message, function(error) {
// check for errors
});
const message = {foo: 'bar'}
const rooms = ['notifications', 'lounge'];
sd.publish(rooms, message, function(error) {
// check for errors
});
sd.channelStats(function(error, reply) {
// check for errors
console.log(reply); // { users_count: 2 }
});
sd.members(function(error, reply) {
// check for errors
console.log(reply); // ['bcI:GPhz6A2T', 'b58:fnaJaEfh']
});
sd.rooms(function(error, reply) {
// check for errors
console.log(reply); // ["room1", "room2"]
});
sd.roomMembers('my-room', function(error, reply) {
// check for errors
console.log(reply); // ['bcI:GPhz6A2T', 'b58:fnaJaEfh']
});
sd.allRoomMembers(function(error, reply) {
// check for errors
console.log(reply); // {"room1": ["user1", "user2"], "room2": ["user1"]}
});