interface InputPacketJSONDecoded {
    command: string
    data: any
}

type onReceiveCallback = (data: any) => void
export default abstract class InputPacket {
    onreceive: onReceiveCallback | null = null

    onReceive (callback: onReceiveCallback): void {
        this.onreceive = callback
    }
    abstract identifier (): string

    recv (packet: InputPacketJSONDecoded): void {
        if (this.onreceive !== null) {
            this.onreceive(packet.data)
        }
    }
}