From 2a8efea29a77b2b7aa83279d2338ec3ec4e2b86c Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Thu, 3 Nov 2016 12:27:19 +0000 Subject: [PATCH] use browser 'online' event to trigger reconnect --- .../public/coffee/ide/connection/ConnectionManager.coffee | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/services/web/public/coffee/ide/connection/ConnectionManager.coffee b/services/web/public/coffee/ide/connection/ConnectionManager.coffee index 0791e2ddc4..3552c335df 100644 --- a/services/web/public/coffee/ide/connection/ConnectionManager.coffee +++ b/services/web/public/coffee/ide/connection/ConnectionManager.coffee @@ -20,6 +20,12 @@ define [], () -> @disconnectIfInactive() , ONEHOUR) + # trigger a reconnect immediately if network comes back online + window.addEventListener 'online', => + sl_console.log "[online] browser notified online" + if !@connected + @tryReconnectWithRateLimit({force:true}) + @userIsLeavingPage = false window.addEventListener 'beforeunload', => @userIsLeavingPage = true