[Libreoffice-commits] online.git: loleaflet/src

Henry Castro hcastro at collabora.com
Sun Sep 17 14:51:31 UTC 2017


 loleaflet/src/core/Socket.js |   28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

New commits:
commit 0cdf36151094188679efa86fd9ae1b4a5976263f
Author: Henry Castro <hcastro at collabora.com>
Date:   Sun Sep 17 10:45:59 2017 -0400

    loleaflet: clean up the socket connection
    
    Change-Id: I29861d74ba5e0aa789eec41fb353aca1dad6cce4

diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index bf45d685..d6243113 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -23,25 +23,27 @@ L.Socket = L.Class.extend({
 
 	connect: function() {
 		var map = this._map;
+		if (map.options.permission) {
+			map.options.docParams['permission'] = map.options.permission;
+		}
+		var wopiSrc = '';
+		if (map.options.wopiSrc != '') {
+			wopiSrc = '?WOPISrc=' + map.options.wopiSrc + '&compat=/ws';
+		}
+
 		try {
-			if (map.options.permission) {
-				map.options.docParams['permission'] = map.options.permission;
-			}
-			var wopiSrc = '';
-			if (map.options.wopiSrc != '') {
-				wopiSrc = '?WOPISrc=' + map.options.wopiSrc + '&compat=/ws';
-			}
 			this.socket = new WebSocket(map.options.server + '/lool/' + encodeURIComponent(map.options.doc + '?' + $.param(map.options.docParams)) + '/ws' + wopiSrc);
-			this.socket.onerror = L.bind(this._onSocketError, this);
-			this.socket.onclose = L.bind(this._onSocketClose, this);
-			this.socket.onopen = L.bind(this._onSocketOpen, this);
-			this.socket.onmessage = L.bind(this._onMessage, this);
-			this.socket.binaryType = 'arraybuffer';
 		} catch (e) {
 			this._map.fire('error', {msg: _('Oops, there is a problem connecting to LibreOffice Online : ' + e), cmd: 'socket', kind: 'failed', id: 3});
-			return null;
+			return;
 		}
 
+		this.socket.onerror = L.bind(this._onSocketError, this);
+		this.socket.onclose = L.bind(this._onSocketClose, this);
+		this.socket.onopen = L.bind(this._onSocketOpen, this);
+		this.socket.onmessage = L.bind(this._onMessage, this);
+		this.socket.binaryType = 'arraybuffer';
+
 		if (map.options.docParams.access_token && parseInt(map.options.docParams.access_token_ttl)) {
 			var tokenExpiryWarning = 900 * 1000; // Warn when 15 minutes remain
 			clearTimeout(this._accessTokenExpireTimeout);


More information about the Libreoffice-commits mailing list