(
socket: Socket<ListenEvents, EmitEvents, ServerSideEvents, SocketData>,
fn: (
socket: Socket<ListenEvents, EmitEvents, ServerSideEvents, SocketData>,
) => void,
)
| 406 | } |
| 407 | |
| 408 | private _doConnect( |
| 409 | socket: Socket<ListenEvents, EmitEvents, ServerSideEvents, SocketData>, |
| 410 | fn: ( |
| 411 | socket: Socket<ListenEvents, EmitEvents, ServerSideEvents, SocketData>, |
| 412 | ) => void, |
| 413 | ) { |
| 414 | this._preConnectSockets.delete(socket.id); |
| 415 | this.sockets.set(socket.id, socket); |
| 416 | |
| 417 | // it's paramount that the internal `onconnect` logic |
| 418 | // fires before user-set events to prevent state order |
| 419 | // violations (such as a disconnection before the connection |
| 420 | // logic is complete) |
| 421 | socket._onconnect(); |
| 422 | if (fn) fn(socket); |
| 423 | |
| 424 | // fire user-set events |
| 425 | this.emitReserved("connect", socket); |
| 426 | this.emitReserved("connection", socket); |
| 427 | } |
| 428 | |
| 429 | /** |
| 430 | * Removes a client. Called by each `Socket`. |
no test coverage detected