Reputation: 9934
will my server be notified about disconnect on the client side? I assume the answer is yes if the disconnect happens explictly like below.
pusher.disconnect()
however what happens if the user simply closes the browser?
Another thing is there a way to notify the server that a certain channel has not been in use by the client(s) for some while?
Upvotes: 3
Views: 8716
Reputation: 15467
The connection states documentation shows how to bind to connection state changes.
however what happens if the user simply closes the browser?
This really depends on if the browser calls webSocketInstance.onclose
so the Pusher JavaScript library is informed before the browser is closed. You could always detect this yourself using window.onbeforeunload
, window.onunload
or the addEventListener
versions.
Another thing is there a way to notify the server that a certain channel has not been in use by the client(s) for some while?
You can use WebHooks so that when a channel becomes vacated your app server will be informed.
Upvotes: 6