Reputation: 1014
Is there a way to setup pusher authentication for private channels using Meteor? I looked in Atmosphere for a pusher package and didn't see one.
Upvotes: 1
Views: 359
Reputation: 1014
After some digging the solution I found was not very difficult to implement. Here are the steps.
mrt add npm
"pusher": "0.1.3"
to packages.json
server
directory of your project. Be sure to change the appId
, key
, and secret
to be the correct ones for your app.if (Meteor.isServer) {
var Pusher = Meteor.require('pusher');
var pusher = new Pusher( { appId: '12345', key: 'keytext', secret: 'secrettext' } );
Meteor.Router.add('/pusher/auth','POST', function(){
var req = this.request;
var res = this.response;
var socketId = req.body.socket_id;
var channel = req.body.channel_name;
var auth = pusher.auth( socketId, channel );
res.write(JSON.stringify(auth));
})
}
Upvotes: 2