(
uri?: string | Partial<ManagerOptions>,
opts?: Partial<ManagerOptions>,
)
| 155 | opts?: Partial<ManagerOptions>, |
| 156 | ); |
| 157 | constructor( |
| 158 | uri?: string | Partial<ManagerOptions>, |
| 159 | opts?: Partial<ManagerOptions>, |
| 160 | ) { |
| 161 | super(); |
| 162 | if (uri && class="st">"object" === typeof uri) { |
| 163 | opts = uri; |
| 164 | uri = undefined; |
| 165 | } |
| 166 | opts = opts || {}; |
| 167 | |
| 168 | opts.path = opts.path || class="st">"/socket.io"; |
| 169 | this.opts = opts; |
| 170 | installTimerFunctions(this, opts); |
| 171 | this.reconnection(opts.reconnection !== false); |
| 172 | this.reconnectionAttempts(opts.reconnectionAttempts || Infinity); |
| 173 | this.reconnectionDelay(opts.reconnectionDelay || 1000); |
| 174 | this.reconnectionDelayMax(opts.reconnectionDelayMax || 5000); |
| 175 | this.randomizationFactor(opts.randomizationFactor ?? 0.5); |
| 176 | this.backoff = new Backoff({ |
| 177 | min: this.reconnectionDelay(), |
| 178 | max: this.reconnectionDelayMax(), |
| 179 | jitter: this.randomizationFactor(), |
| 180 | }); |
| 181 | this.timeout(null == opts.timeout ? 20000 : opts.timeout); |
| 182 | this._readyState = class="st">"closed"; |
| 183 | this.uri = uri as string; |
| 184 | const _parser = opts.parser || parser; |
| 185 | this.encoder = new _parser.Encoder(); |
| 186 | this.decoder = new _parser.Decoder(); |
| 187 | this._autoConnect = opts.autoConnect !== false; |
| 188 | if (this._autoConnect) this.open(); |
| 189 | } |
| 190 | |
| 191 | /** |
| 192 | * Sets the `reconnection` config. |
nothing calls this directly
no test coverage detected