* Called upon transport considered open. * * @private
()
| 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. |
no test coverage detected