Question

Currently I have a server-side user list that is pulled down by a User A's browser and then tracks locally the state of the system via pusher as users log on or off.

As User A's status changes, it sends ajax updates to the server to notify its status.

I am having de-sync issues with the status of users that are pulled down from the database vs the local tracking of the state in the browser while it is keeping track of users on the channel.

I would like to create a server-side observer that is constantly monitoring the pusher channels and acts as redundant method to sync the clients browser to the database.

Can anyone point me in the right direction of a good solution to use for the following necessary functions:

-Needs to integrate with pusher and be able to listen to/respond to events, not just send json messages over the channel

-Needs to receive all events that are published on a channel

I am unsure what libraries or solutions exist that can listen to Pusher channel events on the server.

Any suggestions would be much appreciated.

Was it helpful?

Solution

The best solution for this is to use Pusher's WebHooks. The benefit of this is that you can receive a number of events related to user activity and all events will be delivered i.e. failures are queued and resent.

There are no language requirements to consuming WebHooks as it's just an HTTP request made from Pusher to an endpoint that you define.

Right now you can receive channel vacated and occupied events (if a channel has any subscribers or none) and presence events (users joining and leaving a channel). It's likely that Pusher will expose additional events as WebHooks in the future.

If you were to run a daemon process which connects as a client there is the possibility of missing events during times where the client isn't connected e.g. network downtime or reconnection phases.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top