taoensso / sente

Realtime web comms library for Clojure/Script
https://www.taoensso.com/sente
Eclipse Public License 1.0
1.73k stars 193 forks source link

Triggering :chsk/uidport-close event only 5 seconds after a WebSocket channel is closed #414

Closed khmelevskii closed 1 year ago

khmelevskii commented 1 year ago

Can I configure this 5 second? For example I'm going to use 1500ms. In case that I will be able to change this value it will influence to something?

ptaoussanis commented 1 year ago

@khmelevskii Hi Yurii. No, currently this isn't configurable.

Should be easy to make this configurable here, PR welcome. Would suggest this value be separately configurable for WebSockets and Ajax, both defaulting to 5000 msecs: e.g. :msecs-allow-reconnect-before-close-ws, :msecs-allow-reconnect-before-close-ajax.

Just curious - what's your motivation in wanting a shorter timeout here?

khmelevskii commented 1 year ago

@ptaoussanis great, I will create PR.

About motivation. In my app I have user online/offline status on UI. To show this I'm using :chsk/uidport-open and :chsk/uidport-close events. When :chsk/uidport-close triggered I'm checking connected-uid and if user doen't exist (doesn't have connected other clients)I set status of this user to "offline".

ptaoussanis commented 1 year ago

When :chsk/uidport-close triggered I'm checking connected-uid and if user doen't exist (doesn't have connected other clients)I set status of this user to "offline".

So that's a typical use case, but what's your motivation for reducing the timeout specifically? Note that there's tradeoffs with a lower timeout - you'll get more false-positive :chsk/uidport-close events with a lower timeout. I.e. could make your online/offline status UI more noisy.

khmelevskii commented 1 year ago

I think this is totally fine to be more noisy here. For example I can see that status in Slack updates immediately (when user refresh slack page I can see that his status blink).

ptaoussanis commented 1 year ago

Great, thanks for the confirmation. PR welcome 👍

ptaoussanis commented 1 year ago

Closing, this will be included in forthcoming v1.18 👍