lundi 5 janvier 2015

Ember Pusher - how do dynamic channel subscriptions work?

How can I get client-side events to work with dynamic channels based on each user?


I have a listening controller which listens to events being triggered from a backend defined like so:


LISTENING CONTROLLER



export default Ember.ObjectController.extend(window.EmberPusher.Bindings, window.EmberPusher.ClientEvents, {
init: function(){
var channel = this.get('pusher.connection').subscribe('channel_'+this.get('session').user_id);
PUSHER_SUBSCRIPTIONS: {channel: ['message_received']}
},
actions: {
messageReceived: function(){
alert("client user messages is working!");
}
}
});


The backend is triggering events like so:



$channel_name = "channel_".(string)$receiver_id;
$pusher->trigger($channel_name, (string)$n_type, $data);


It's tough to debug the problem because nothing is happening. Is there something blatantly wrong with how the pusher flow is being handled?





Aucun commentaire:

Enregistrer un commentaire