import { PacketType } from "./PacketType.ts"; import { hasEmptyFlags, isEmptyBuf } from "./decoder.ts"; import type { CodecOpts } from "./types.ts"; import type { ProtocolLevel } from "./protocolLevels.ts"; /** * PingreqPacket is a packet that is sent to the server to keep the connection alive */ export type PingreqPacket = { type: PacketType; protocolLevel: ProtocolLevel; }; const PINGRES_PACKET = new Uint8Array([PacketType.pingreq << 4, 0]); export function encode( _packet: PingreqPacket, _codecOpts: CodecOpts, ): Uint8Array { return PINGRES_PACKET; } export function decode( buffer: Uint8Array, flags: number, codecOpts: CodecOpts, _packetType: PacketType, ): PingreqPacket { hasEmptyFlags(flags); isEmptyBuf(buffer); return { type: PacketType.pingreq, protocolLevel: codecOpts.protocolLevel, }; }