| 57 | } |
| 58 | |
| 59 | private onDisconnect(destroyedSocket: Socket) { |
| 60 | let disconnectedClientId: string | undefined |
| 61 | |
| 62 | for (const [clientId, socket] of this._clients.entries()) { |
| 63 | if (socket === destroyedSocket) { |
| 64 | disconnectedClientId = clientId |
| 65 | this._clients.delete(clientId) |
| 66 | break |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | this.log(`[server#socket.disconnected] clientId = ${disconnectedClientId}, # clients = ${this._clients.size}`) |
| 71 | |
| 72 | if (disconnectedClientId) { |
| 73 | this.emit(IpcMessageType.Disconnect, disconnectedClientId) |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | private onMessage(data: unknown) { |
| 78 | if (typeof data !== "object") { |