* Produces an ack callback to emit with an event. * * @param {Number} id - packet id * @private
(id: number)
| 581 | * @private |
| 582 | */ |
| 583 | private ack(id: number): () => void { |
| 584 | const self = this; |
| 585 | let sent = false; |
| 586 | return function () { |
| 587 | // prevent double callbacks |
| 588 | if (sent) return; |
| 589 | const args = Array.prototype.slice.call(arguments); |
| 590 | debug("sending ack %j", args); |
| 591 | |
| 592 | self.packet({ |
| 593 | id: id, |
| 594 | type: PacketType.ACK, |
| 595 | data: args, |
| 596 | }); |
| 597 | |
| 598 | sent = true; |
| 599 | }; |
| 600 | } |
| 601 | |
| 602 | /** |
| 603 | * Called upon ack packet. |