Interface declaring handling of received packets. When receiving a packet, its content is sent to feed(), and codec is supposed to emit packet or error event when packet is parsed.

interface IPacketCodec {
    encode(packet: Uint8Array): MaybePromise<Uint8Array>;
    feed(data: Uint8Array): void;
    on(event: "error", handler: ((error: Error) => void)): void;
    on(event: "packet", handler: ((packet: Uint8Array) => void)): void;
    removeAllListeners(): void;
    reset(): void;
    setup?(crypto: ICryptoProvider, log: Logger): void;
    tag(): MaybePromise<Uint8Array>;
}

Implemented by

Methods