Skip to content

Commit 18d2cb4

Browse files
committed
Added an alwaysReconnect option
The new option specifies whether the socket should try to reconnect every time it is closed as opposed to reconnecting only for certain close codes.
1 parent d6b89fb commit 18d2cb4

9 files changed

+215
-59
lines changed

angular-websocket.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
this._reconnectAttempts = options && options.reconnectAttempts || 0;
5555
this.initialTimeout = options && options.initialTimeout || 500; // 500ms
5656
this.maxTimeout = options && options.maxTimeout || 5 * 60 * 1000; // 5 minutes
57+
this.alwaysReconnect = options && options.alwaysReconnect || false;
5758

5859
this.sendQueue = [];
5960
this.onOpenCallbacks = [];
@@ -182,7 +183,7 @@
182183

183184
$WebSocket.prototype._onCloseHandler = function _onCloseHandler(event) {
184185
this.notifyCloseCallbacks(event);
185-
if (this._reconnectableStatusCodes.indexOf(event.code) > -1) {
186+
if (this.alwaysReconnect || this._reconnectableStatusCodes.indexOf(event.code) > -1) {
186187
this.reconnect();
187188
}
188189
};

angular-websocket.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)