MCPcopy
hub / github.com/socketio/socket.io / constructor

Method constructor

packages/socket.io-client/lib/manager.ts:157–189  ·  packages/socket.io-client/lib/manager.ts::Manager.constructor
(
    uri?: string | Partial<ManagerOptions>,
    opts?: Partial<ManagerOptions>,
  )

Source from the content-addressed store, hash-verified

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.

Callers

nothing calls this directly

Calls 8

reconnectionMethod · 0.95
reconnectionAttemptsMethod · 0.95
reconnectionDelayMethod · 0.95
reconnectionDelayMaxMethod · 0.95
randomizationFactorMethod · 0.95
timeoutMethod · 0.95
openMethod · 0.95
installTimerFunctionsFunction · 0.90

Tested by

no test coverage detected