67P / hyperchannel

Kosmos Chat for the Web
Mozilla Public License 2.0
20 stars 3 forks source link

Disconnect from servers immediately when closing Hyperchannel #149

Open raucao opened 6 years ago

silverbucket commented 6 years ago

Not totally sure the context here, but I purposefully left this at an idle timeout in sockethub before closing the connection, in order to not have people disconnect/reconnect every time there's a page refresh.

raucao commented 6 years ago

Context is closing the app in normal use, and still being shown as online, thus not receiving push notifications for mentions until the idle time is over and Sockethub quits.

I think this should probably just be different in development and production, as you shouldn't need to reload the app in production at all, whereas in development you'd want to stay connected while you reload all the time.

silverbucket commented 6 years ago

@skddc This is something I considered when implementing Sockethub and it's extremely easy to get into weird connection states when a page is refreshed and we immediately initiate disconnects while also simultaneously initiating new connections to the same targets all essentially at the same time (which is what happens during a page reload).

I don't think we should prescribe that a user should never need to refresh the page (though I agree we should aim that they never need to do this due to technical reasons). We could lower the connection timeout, or send a different signal if we can guess that the page was closed rather than reloaded (not sure if that's possible with browser events?)

silverbucket commented 6 years ago

Could you elaborate on the issue with providing a reasonable timeout before disconnect? Why wouldn't push notifications work? Couldn't it keep track of whether the page is opened on a tab somewhere as it's running in the same browser as a ServiceWorker I assume?