(
packet: any,
opts: BroadcastOptions,
clientCountCallback: (clientCount: number) => void,
ack: (...args: any[]) => void,
)
| 474 | } |
| 475 | |
| 476 | override broadcastWithAck( |
| 477 | packet: any, |
| 478 | opts: BroadcastOptions, |
| 479 | clientCountCallback: (clientCount: number) => void, |
| 480 | ack: (...args: any[]) => void, |
| 481 | ) { |
| 482 | const onlyLocal = opts?.flags?.local; |
| 483 | if (!onlyLocal) { |
| 484 | const requestId = randomId(); |
| 485 | |
| 486 | this.ackRequests.set(requestId, { |
| 487 | clientCountCallback, |
| 488 | ack, |
| 489 | }); |
| 490 | |
| 491 | this.publish({ |
| 492 | type: MessageType.BROADCAST, |
| 493 | data: { |
| 494 | packet, |
| 495 | requestId, |
| 496 | opts: encodeOptions(opts), |
| 497 | }, |
| 498 | }); |
| 499 | |
| 500 | // we have no way to know at this level whether the server has received an acknowledgement from each client, so we |
| 501 | // will simply clean up the ackRequests map after the given delay |
| 502 | setTimeout(() => { |
| 503 | this.ackRequests.delete(requestId); |
| 504 | }, opts.flags!.timeout); |
| 505 | } |
| 506 | |
| 507 | super.broadcastWithAck(packet, opts, clientCountCallback, ack); |
| 508 | } |
| 509 | |
| 510 | override async addSockets(opts: BroadcastOptions, rooms: Room[]) { |
| 511 | const onlyLocal = opts.flags?.local; |
nothing calls this directly
no test coverage detected