user3995789 user3995789 - 1 year ago 107
Javascript Question

How to send events to a single client with pusher pubnub socketio

I am building a multiplayer turn based game, the communication between clients and server is established with Pusher. I can send events to all clients using game channels. The problem is how do I send an event to a single client? Pusher has no documentation for it, only seemingly solution is to use authenticated channels. Is it viable to authenticate a dedicated channel for every client sending events to a single client, or is there a better solution?

Answer Source

You touched on the best solution in your answer. You should be able to quite easily programmatically setup channels for each individual user and then just broadcast messages to them over those channels.

e.g. (this is a Ruby example but it should be clear what's happening)

Pusher.trigger("card-data-#{}", 'card-update', {data: {card_id: 1, status: 'used'})

or something like that. Obviously you'd then need to make sure that on the client side that the users are subscribing to the correct channels.

Obviously if you need the channels to be secure then, as you said, you can use authenticated channels - probably using private channels makes sense in your case.

If you have any more questions then you can reply here again and I'll take a look, or you can email support at

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download