import { _decorator, Component, js, Node } from 'cc';
import { gameSocket } from './gameSocket';
import { config } from '../config';
import { userDataManager } from '../manager/userDataManager';
import { ClientEvent } from '../lib/clientEvent';
const { ccclass, property } = _decorator;

@ccclass('msgManager')
export class msgManager extends Component {
    
    // 发送重连
    public static relink(){
        let str = JSON.stringify({"action":"open", "user_id":userDataManager.user_data.id})
        console.log("发送一次重连请求",str)
        gameSocket.Instance.send_cmd(str)
    }

    // 接受消息
    public static recv(json_data){
        console.log("接收消息",json_data)
        let json = JSON.parse(json_data)
        ClientEvent.dispatchEvent(config.EVENT_TYPE.MSG_DATA,json)
        // switch (json.action) {
        //     case 0:
        //         break;
        //     case config.MSG_TYPE.guangbo:
        //         break;
        //     case config.MSG_TYPE.announcement:
        //         break;
        //     case config.MSG_TYPE.mail:
        //         break;
        //     default:
        //         break;
        // }
    }

    
}

