* Produces an ack callback to emit with an event. * * @param {Number} id - packet id * @private
(id: number)
| 674 | * @private |
| 675 | */ |
| 676 | private ack(id: number): () => void { |
| 677 | const self = this; |
| 678 | let sent = false; |
| 679 | return function () { |
| 680 | // prevent double callbacks |
| 681 | if (sent) return; |
| 682 | const args = Array.prototype.slice.call(arguments); |
| 683 | debug("sending ack %j", args); |
| 684 | |
| 685 | self.packet({ |
| 686 | id: id, |
| 687 | type: PacketType.ACK, |
| 688 | data: args, |
| 689 | }); |
| 690 | |
| 691 | sent = true; |
| 692 | }; |
| 693 | } |
| 694 | |
| 695 | /** |
| 696 | * Called upon ack packet. |