loleaflet/src/core/Socket.js | 43 ++++++++++++++++++++++++++++++++++++++----- loleaflet/src/map/Map.js | 2 +- 2 files changed, 39 insertions(+), 6 deletions(-)
New commits: commit 6b7219e25a3a7b1517b3a8a3fe6245f77c0f15f1 Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Sat Nov 19 11:22:19 2016 -0500 loleaflet: notify the user when server intentionally closes connection Change-Id: I82d855c1a50dca42e40d1123e42b0e02227f73d1 Reviewed-on: https://gerrit.libreoffice.org/31003 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js index 1c124fb..7d802ae 100644 --- a/loleaflet/src/core/Socket.js +++ b/loleaflet/src/core/Socket.js @@ -186,15 +186,48 @@ L.Socket = L.Class.extend({ } else if (textMsg.startsWith('close: ')) { textMsg = textMsg.substring('close: '.length); + msg = ''; // This is due to document owner terminating the session if (textMsg === 'ownertermination') { - // Disconnect the websocket manually - this.close(); - // Tell WOPI host about it which should handle this situation - this._map.fire('postMessage', {msgId: 'Session_Closed'}); - } + msg = _('Session terminated by document owner'); + } + else if (textMsg === 'shutdown') { + msg = _('Server shutdown for maintenance'); + } + + var options = $.extend({}, vex.defaultOptions, { + contentCSS: {'background':'rgba(0, 0, 0, 0)', + 'font-size': 'xx-large', + 'color': '#fff', + 'text-align': 'center'}, + content: msg + }); + options.id = vex.globalID; + vex.dialogID = options.id; + vex.globalID += 1; + options.$vex = $('<div>').addClass(vex.baseClassNames.vex).addClass(options.className).css(options.css).data({ + vex: options + }); + options.$vexOverlay = $('<div>').addClass(vex.baseClassNames.overlay).addClass(options.overlayClassName).css(options.overlayCSS).data({ + vex: options + }); + + options.$vex.append(options.$vexOverlay); + + options.$vexContent = $('<div>').addClass(vex.baseClassNames.content).addClass(options.contentClassName).css(options.contentCSS).text(options.content).data({ + vex: options + }); + options.$vex.append(options.$vexContent); + + $(options.appendLocation).append(options.$vex); + vex.setupBodyClassName(options.$vex); + + // Disconnect the websocket manually + this.close(); + // Tell WOPI host about it which should handle this situation + this._map.fire('postMessage', {msgId: 'Session_Closed'}); this._map.remove(); return; diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js index c489f73..75e20fc 100644 --- a/loleaflet/src/map/Map.js +++ b/loleaflet/src/map/Map.js @@ -778,7 +778,7 @@ L.Map = L.Evented.extend({ var map = this; vex.timer = setTimeout(function() { - if (window.devtools.open) { + if (window.devtools.open || !map._socket.connected()) { return; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits