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

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

export class PacketGroupInviteInfo extends Packet {

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

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

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

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

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

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

    public setMembersCount(count: number) {
        this.membersCount = count;
    }

    public getMembersCount(): number {
        return this.membersCount;
    }

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

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

}