import Packet from "../packet";
import Stream from "../stream";

export class PacketDelivery extends Packet {

    private messageId: string = "";
    private toPublicKey: string = "";

    public getPacketId(): number {
        return 0x08;
    }

    public _receive(stream: Stream): void {
        this.toPublicKey = stream.readString();
        this.messageId = stream.readString();
    }

    public _send(): Stream {
        const stream = new Stream();
        stream.writeInt16(this.getPacketId());
        stream.writeString(this.toPublicKey);
        stream.writeString(this.messageId);
        return stream;
    }

    public setMessageId(messageId: string) {
        this.messageId = messageId;
    }

    public getMessageId(): string {
        return this.messageId;
    }

    public setToPublicKey(toPublicKey: string) {
        this.toPublicKey = toPublicKey;
    }

    public getToPublicKey(): string {
        return this.toPublicKey;
    }

}