//import TsdkFacade from '../TSDK/TsdkFacade';
import BehaviorBase from '../Framework/BehaviorBase';
import DataModelManager from '../Framework/DataModelManager'

export default class ChatBehavior extends BehaviorBase
{
    // 
    onHandleInGameTalk(notify) {
        let obj = {};

        obj.tableID = notify.TableID.tvalue;
        obj.roomID = notify.RoomID.tvalue;
        obj.srcPlayerId = notify.SrcPlayerId.tvalue;
        obj.dstPlayerId = notify.DstPlayerId.tvalue;
        obj.type = notify.Type.tvalue;
        obj.talkID = notify.TalkID.tvalue;
        obj.msg = notify.Msg.tvalue;
        obj.nick = notify.Nick.tvalue;

        let playerModel = this.dmm.getModel("PlayerInfoModel");
        //let playerSeatId = playerModel.getPlayerinfoByPlayerId(obj.srcPlayerId);

        console.log("nick: " + obj.nick + " talk: " + obj.talkID + " type: " + obj.type + " seatid: " + playerSeatId);

        this.emit('inGameTalk', playerSeatId, obj.type, obj.talkID);
    }

    // 注册监听
    registerHandlers() {
      //  this.tsdk.registerGameSvrMsgCallback(tsdk.TSMsgPara.TSHuanLeGameSvr.MSGID_S2C_HG_PUSHTABLEMSGS, this.onHandleInGameTalk.bind(this));
    }

    constructor()
    {
        super();
      //  this.tsdk = TsdkFacade.getCore();
        this.dmm = DataModelManager;

        this.registerHandlers();
    }

    reqSendChat(chatIdx)
    {
        console.log("reqSendChat");
        let playerModel = this.dmm.getModel("PlayerInfoModel");
        let tableid = playerModel.tableId;
        console.log("tableid: " + tableid + "  chatIdx: " + chatIdx);
        // this.tsdk.reqTalkOnTable(
        //     tsdk.TSMsgPara.TSHuanLeGameSvr.TALK_BROADCAST,
        //     tableid,
        //     tsdk.TSMsgPara.TSHuanLeGameSvr.TALK_TYPE.ETT_VOICE,
        //     chatIdx, "");
    }
}