From 65150d16a72564c27acc087ebfac8f03fbaccebc Mon Sep 17 00:00:00 2001 From: Flavio Curella Date: Wed, 13 Sep 2017 10:32:40 -0700 Subject: [PATCH] recompile js bundles from master (#736) --- .../static/channels/js/websocketbridge.js | 25 +++++++++++++------ js_client/lib/index.js | 4 ++- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/channels/static/channels/js/websocketbridge.js b/channels/static/channels/js/websocketbridge.js index e5650e4..e9aaab4 100644 --- a/channels/static/channels/js/websocketbridge.js +++ b/channels/static/channels/js/websocketbridge.js @@ -3,6 +3,9 @@ */ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.channels = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o config.maxRetries) { @@ -107,15 +112,19 @@ var ReconnectingWebsocket = function (url, protocols, options) { else { reconnectDelay = updateReconnectionDelay(config, reconnectDelay); } - log('reconnectDelay:', reconnectDelay); + log('handleClose - reconnectDelay:', reconnectDelay); if (shouldRetry) { setTimeout(connect, reconnectDelay); } }; var connect = function () { + if (!shouldRetry) { + return; + } log('connect'); var oldWs = ws; - ws = new config.constructor(url, protocols); + var wsUrl = (typeof url === 'function') ? url() : url; + ws = new config.constructor(wsUrl, protocols); connectingTimeout = setTimeout(function () { log('timeout'); ws.close(); @@ -147,10 +156,11 @@ var ReconnectingWebsocket = function (url, protocols, options) { if (code === void 0) { code = 1000; } if (reason === void 0) { reason = ''; } var _b = _a === void 0 ? {} : _a, _c = _b.keepClosed, keepClosed = _c === void 0 ? false : _c, _d = _b.fastClose, fastClose = _d === void 0 ? true : _d, _e = _b.delay, delay = _e === void 0 ? 0 : _e; + log('close - params:', { reason: reason, keepClosed: keepClosed, fastClose: fastClose, delay: delay, retriesCount: retriesCount, maxRetries: config.maxRetries }); + shouldRetry = !keepClosed && retriesCount <= config.maxRetries; if (delay) { reconnectDelay = delay; } - shouldRetry = !keepClosed; ws.close(code, reason); if (fastClose) { var fakeCloseEvent_1 = { @@ -205,6 +215,7 @@ var ReconnectingWebsocket = function (url, protocols, options) { } ws.removeEventListener(type, listener, options); }; + return this; }; module.exports = ReconnectingWebsocket; @@ -259,7 +270,7 @@ var WebSocketBridge = function () { * @param {String} [url] The url of the websocket. Defaults to * `window.location.host` * @param {String[]|String} [protocols] Optional string or array of protocols. - * @param {Object} options Object of options for [`reconnecting-websocket`](https://github.com/joewalnes/reconnecting-websocket#options-1). + * @param {Object} options Object of options for [`reconnecting-websocket`](https://github.com/pladaria/reconnecting-websocket#configure). * @example * const webSocketBridge = new WebSocketBridge(); * webSocketBridge.connect(); diff --git a/js_client/lib/index.js b/js_client/lib/index.js index 0e69313..c2a6e8c 100644 --- a/js_client/lib/index.js +++ b/js_client/lib/index.js @@ -48,7 +48,7 @@ var WebSocketBridge = function () { * @param {String} [url] The url of the websocket. Defaults to * `window.location.host` * @param {String[]|String} [protocols] Optional string or array of protocols. - * @param {Object} options Object of options for [`reconnecting-websocket`](https://github.com/joewalnes/reconnecting-websocket#options-1). + * @param {Object} options Object of options for [`reconnecting-websocket`](https://github.com/pladaria/reconnecting-websocket#configure). * @example * const webSocketBridge = new WebSocketBridge(); * webSocketBridge.connect(); @@ -72,6 +72,8 @@ var WebSocketBridge = function () { _url = url; } } + // Some mobile devices (eg: HTC M8, SAMSUNG Galaxy S8) will get error code + // [1006] during handshake if `protocols` is `undefined`. var _protocols = protocols === undefined ? '' : protocols; this.socket = new _reconnectingWebsocket2.default(_url, _protocols, options); }