| 43 | } |
| 44 | |
| 45 | private onConnect(socket: Socket) { |
| 46 | const clientId = crypto.randomBytes(6).toString("hex") |
| 47 | this._clients.set(clientId, socket) |
| 48 | this.log(`[server#onConnect] clientId = ${clientId}, # clients = ${this._clients.size}`) |
| 49 | |
| 50 | this.send(socket, { |
| 51 | type: IpcMessageType.Ack, |
| 52 | origin: IpcOrigin.Server, |
| 53 | data: { clientId, pid: process.pid, ppid: process.ppid }, |
| 54 | }) |
| 55 | |
| 56 | this.emit(IpcMessageType.Connect, clientId) |
| 57 | } |
| 58 | |
| 59 | private onDisconnect(destroyedSocket: Socket) { |
| 60 | let disconnectedClientId: string | undefined |