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

Method onOpen

packages/engine.io/lib/socket.ts:116–145  ·  view source on GitHub ↗

* Called upon transport considered open. * * @private

()

Source from the content-addressed store, hash-verified

114 * @private
115 */
116 private onOpen() {
117 this.readyState = "open";
118
119 // sends an `open` packet
120 this.transport.sid = this.id;
121 this.sendPacket(
122 "open",
123 JSON.stringify({
124 sid: this.id,
125 upgrades: this.getAvailableUpgrades(),
126 pingInterval: this.server.opts.pingInterval,
127 pingTimeout: this.server.opts.pingTimeout,
128 maxPayload: this.server.opts.maxHttpBufferSize,
129 }),
130 );
131
132 if (this.server.opts.initialPacket) {
133 this.sendPacket("message", this.server.opts.initialPacket);
134 }
135
136 this.emit("open");
137
138 if (this.protocol === 3) {
139 // in protocol v3, the client sends a ping, and the server answers with a pong
140 this.resetPingTimeout();
141 } else {
142 // in protocol v4, the server sends a ping, and the client answers with a pong
143 this.schedulePing();
144 }
145 }
146
147 /**
148 * Called upon transport packet.

Callers 1

constructorMethod · 0.95

Calls 5

sendPacketMethod · 0.95
getAvailableUpgradesMethod · 0.95
emitMethod · 0.95
resetPingTimeoutMethod · 0.95
schedulePingMethod · 0.95

Tested by

no test coverage detected