diff --git a/channels/static/channels/js/websocketbridge.js b/channels/static/channels/js/websocketbridge.js index e9aaab4..d7b2845 100644 --- a/channels/static/channels/js/websocketbridge.js +++ b/channels/static/channels/js/websocketbridge.js @@ -3,9 +3,6 @@ */ (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) { @@ -112,19 +107,15 @@ var ReconnectingWebsocket = function (url, protocols, options) { else { reconnectDelay = updateReconnectionDelay(config, reconnectDelay); } - log('handleClose - reconnectDelay:', reconnectDelay); + log('reconnectDelay:', reconnectDelay); if (shouldRetry) { setTimeout(connect, reconnectDelay); } }; var connect = function () { - if (!shouldRetry) { - return; - } log('connect'); var oldWs = ws; - var wsUrl = (typeof url === 'function') ? url() : url; - ws = new config.constructor(wsUrl, protocols); + ws = new config.constructor(url, protocols); connectingTimeout = setTimeout(function () { log('timeout'); ws.close(); @@ -156,11 +147,10 @@ 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 = { @@ -215,7 +205,6 @@ var ReconnectingWebsocket = function (url, protocols, options) { } ws.removeEventListener(type, listener, options); }; - return this; }; module.exports = ReconnectingWebsocket; @@ -270,7 +259,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/pladaria/reconnecting-websocket#configure). + * @param {Object} options Object of options for [`reconnecting-websocket`](https://github.com/joewalnes/reconnecting-websocket#options-1). * @example * const webSocketBridge = new WebSocketBridge(); * webSocketBridge.connect(); @@ -294,10 +283,7 @@ 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); + this.socket = new _reconnectingWebsocket2.default(_url, protocols, options); } /** diff --git a/js_client/lib/index.js b/js_client/lib/index.js index c2a6e8c..53ca4f0 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/pladaria/reconnecting-websocket#configure). + * @param {Object} options Object of options for [`reconnecting-websocket`](https://github.com/joewalnes/reconnecting-websocket#options-1). * @example * const webSocketBridge = new WebSocketBridge(); * webSocketBridge.connect(); @@ -72,10 +72,7 @@ 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); + this.socket = new _reconnectingWebsocket2.default(_url, protocols, options); } /** diff --git a/js_client/package.json b/js_client/package.json index 6c9e36f..91eb348 100644 --- a/js_client/package.json +++ b/js_client/package.json @@ -23,7 +23,7 @@ ], "license": "BSD-3-Clause", "dependencies": { - "reconnecting-websocket": "^3.2.1" + "reconnecting-websocket": "^3.0.3" }, "jest": { "roots": [ diff --git a/js_client/src/index.js b/js_client/src/index.js index e6ca77a..b2ebd81 100644 --- a/js_client/src/index.js +++ b/js_client/src/index.js @@ -30,7 +30,7 @@ export class WebSocketBridge { * @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/pladaria/reconnecting-websocket#configure). + * @param {Object} options Object of options for [`reconnecting-websocket`](https://github.com/joewalnes/reconnecting-websocket#options-1). * @example * const webSocketBridge = new WebSocketBridge(); * webSocketBridge.connect(); @@ -50,10 +50,7 @@ export class WebSocketBridge { _url = url; } } - // Some mobile devices (eg: HTC M8, SAMSUNG Galaxy S8) will get error code - // [1006] during handshake if `protocols` is `undefined`. - const _protocols = protocols === undefined ? '' : protocols; - this.socket = new ReconnectingWebSocket(_url, _protocols, options); + this.socket = new ReconnectingWebSocket(_url, protocols, options); } /**