import Stream from "./stream";

/**
 * Packet abstract class
 */
export default abstract class Packet {

    /**
     * Get the packet ID
     * @returns packet ID
     */
    public abstract getPacketId(): number;
    /**
     * Use the stream to read the packet and fill structure
     * @param stream stream
     */
    public abstract _receive(stream: Stream): void;
    /**
     * Use the stream to write the packet and return the stream
     * @returns stream
     */
    public abstract _send(): Promise<Stream> | Stream;

    public clone(): Packet {
        return new (this as any).constructor();
    }

}