Open metatarz opened 4 years ago
Is there a way to make nchan publish when opening/closing a websocket?
Not sure I understand what exactly do you mean when you say make nchan publish
...
If I'm not mistaken, you want some action to happen on opening/closing a websocket
In that case https://nchan.io/#subscriber-presence is what you need.
Yes, subscriber presence works for me. What would be the equivalent of a 'publisher presence'? In accordance with the docs, nchan_publisher_upstream_request
would do the job but as I checked, it does not upstream requests unless a message is published.
You have two options:
pub
endpoint to pubsub
https://nchan.io/#pubsub-endpoint (though I'm not sure whether callbacks work the same way for pubsub
as they do for sub
sub
endpoint at the same time with connecting to pub
endpoint
In my application, clients open up a new websocket connection by simply instantiating it i.e
new Websocket(pubEndpoint)
; whenever they visit my website and close it down when navigating away or simply closing the tab. I use nginx as a reverse proxy to perform additional server-side logic, and nchan's role is to deal with websocket publish events. My question is: Is there a way to make nchan publish when opening/closing a websocket? My nginx configuration file is the following: