UNPKG

carina

Version:

A NodeJS and Browser compatible client for Mixer.com's constellation socket.

28 lines 1.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * The ExponentialReconnectionPolicy is a policy which reconnects the socket * on a delay specified by the equation min(maxDelay, attempts^2 * baseDelay). */ var ExponentialReconnectionPolicy = /** @class */ (function () { /** * @param {Number} maxDelay maximum duration to wait between reconnection attempts * @param {Number} baseDelay delay, in milliseconds, to use in */ function ExponentialReconnectionPolicy(maxDelay, baseDelay) { if (maxDelay === void 0) { maxDelay = 20 * 1000; } if (baseDelay === void 0) { baseDelay = 500; } this.maxDelay = maxDelay; this.baseDelay = baseDelay; this.retries = 0; } ExponentialReconnectionPolicy.prototype.next = function () { return Math.min(this.maxDelay, (1 << (this.retries++)) * this.baseDelay); }; ExponentialReconnectionPolicy.prototype.reset = function () { this.retries = 0; }; return ExponentialReconnectionPolicy; }()); exports.ExponentialReconnectionPolicy = ExponentialReconnectionPolicy; //# sourceMappingURL=reconnection.js.map