UNPKG

@mixer/interactive-node

Version:

A NodeJS and Browser compatible client for mixer.com's interactive 2 Protocol

29 lines 1.22 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 () { // tslint:disable-next-line:no-bitwise 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