DEV Community

Discussion on: First Ever DEV Contest: Build a Realtime App with Pusher

 
kayis profile image
K

But can I control the client events on my server somehow?

For example, if I want to create a game, I need pipe the client events through some server side logic.

Thread Thread
 
zmarkan profile image
Zan Markan • Edited

You could do that using WebHooks, they allow you to capture all client events on the server - pusher.com/docs/webhooks#client_ev...

Alternatively you could create an API through which the clients would communicate, and the server would broadcast the events.
It really depends on your particular use-case, what kind of events will your clients be creating, and what makes the most sense for it.

Webhooks wouldn't for instance allow you to block client events, only observe them.

Thread Thread
 
vezyank profile image
Slava

How easy would it be to move from socket.io to pusher and vice-versa?

Thread Thread
 
zmarkan profile image
Zan Markan • Edited

As the core concepts of subscriptions, channels, and events are quite similar, it should be a fairly quick migration - but of course it all depends on your concrete project and implementation.

Thread Thread
 
kayis profile image
K • Edited

Is there a way to close user connections on the server?

Thread Thread
 
zmarkan profile image
Zan Markan

I'll double check but I don't think so.

You could send a message to a particular user that you wish to disconnect and handle that clientside.

What is your use-case for this?

Thread Thread
 
kayis profile image
K

I want to use presence channels for games. When a game is finished, the users should be removed from the channel.

Thread Thread
 
zmarkan profile image
Zan Markan

Ah yeah - just send a message that tells the clients to unsub from the channel, that should be the best way.

I've asked the team working on Channels and we don't support terminating connections from the server.

Thread Thread
 
kayis profile image
K

Well, guess for this contest it should be enough, thank you.