Closed Shankar-khati closed 2 years ago
@jondubois, @MegaGM, @sacOO7 can anyone give me any suggestion for the above statement?
@Shankar-khati Sorry for the delay in answer. Maybe you figured it out already.
You can use the 'unsubscribe'
event on the server socket (on a per-socket basis); it triggers when either:
See https://socketcluster.io/docs/api-ag-server-socket/
Alternatively, you can listen to the 'unsubscription'
event on the server (it aggregates all the 'unsubscribe' events from all sockets which are attached to that server/process) - It allows you to perform the unsubscription handling for all sockets and channels from a central place (instead of having to register the handler on a per-socket basis). See https://socketcluster.io/docs/api-ag-server/
Thanks @jondubois for reply. I followed the same but I was looking for some hook or event which we can listen. :)
@Shankar-khati I don't understand. You can listen to that event using a for-await-of
loop.
@jondubois currently I'm listen on subscribe and unsubscribe event on server and maintaining a counter for each channel at my end, just wanted to know if you guys have any event from scc-broker-client or scc-state where I can expect an event when a Channel submitted to garbage collector or when the first subscription happen to the channel.
My use case is simple when the conversation on an SC cluster gets completed I need to dump all data from the cache to persistent. But for that, I'm looking for an event or callback which could be executed just before the channel is garbage collected.