* Called upon a server acknowledgement. * * @param packet * @private
(packet: Packet)
| 806 | * @private |
| 807 | */ |
| 808 | private onack(packet: Packet): void { |
| 809 | const ack = this.acks[packet.id]; |
| 810 | if (typeof ack !== "function") { |
| 811 | debug("bad ack %s", packet.id); |
| 812 | return; |
| 813 | } |
| 814 | delete this.acks[packet.id]; |
| 815 | debug("calling ack %s with %j", packet.id, packet.data); |
| 816 | // @ts-ignore FIXME ack is incorrectly inferred as 'never' |
| 817 | if (ack.withError) { |
| 818 | packet.data.unshift(null); |
| 819 | } |
| 820 | // @ts-ignore |
| 821 | ack.apply(this, packet.data); |
| 822 | } |
| 823 | |
| 824 | /** |
| 825 | * Called upon server connect. |