import { CastSessionVO } from "../../../vo/cast/CastSessionVO";
import { MsgClientType } from "./MsgClientType";
import { MsgType } from "./MsgType";
import { SessionAction } from "./SessionAction";
import { SessionDestroyReason } from "./SessionDestroyReason";
import { YMSMessage } from "./YMSMessage";

export class CastSessionMessage extends YMSMessage {
    castSession: CastSessionVO;
    action: SessionAction;
    mediaPayload: string;
    destroyReason: SessionDestroyReason;

    constructor(sender: MsgClientType, receiver: MsgClientType) {
        super(sender, receiver, MsgType.CAST);
        this.castSession = new CastSessionVO();
        this.action = SessionAction.DESTROY;
        this.mediaPayload = "";
        this.destroyReason = SessionDestroyReason.NONE;
    }

    public getQoS(): number {
        return 1;
    }

    public isRetained(): boolean {
        return false;
    }

    toString(): string {
        return `CastSessionMessage{` +
          `timestamp=${this.timestamp}, ` +
          `sender=${MsgClientType[this.sender]}, ` +
          `receiver='${MsgClientType[this.receiver]}, ` +
          `msgType=${MsgType[this.msgType]}, ` +
          `senderClientId='${this.senderClientId}', ` +
          `castSeesion=${this.castSession.toString()}, ` +
          `action=${SessionAction[this.action]}, ` +
          `mediaPayload='${this.mediaPayload}', ` +
          `destroyReason='${SessionDestroyReason[this.destroyReason]}'` +
          `}`;
    }

}