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

export enum GroupStatus {
    JOINED = 0,
    INVALID = 1,
    NOT_JOINED = 2,
    BANNED = 3
}

export class PacketGroupJoin extends Packet {

    private groupId: string = "";
    private groupStatus: GroupStatus = GroupStatus.NOT_JOINED;

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

    public _receive(stream: Stream): void {
        this.groupId = stream.readString();
        this.groupStatus = stream.readInt8();
    }

    public _send(): Promise<Stream> | Stream {
        const stream = new Stream();
        stream.writeInt16(this.getPacketId());
        stream.writeString(this.groupId);
        stream.writeInt8(this.groupStatus);
        return stream;
    }

    public setGroupId(groupId: string) {
        this.groupId = groupId;
    }

    public getGroupId(): string {
        return this.groupId;
    }

    public setGroupStatus(groupStatus: GroupStatus) {
        this.groupStatus = groupStatus;
    }

    public getGroupStatus(): GroupStatus {
        return this.groupStatus;
    }
    
}