Пример #1
0
    // Use this for initialization
    void Start()
    {
        TestPackBuilder.main();           //初始化
        UnityThreadHelper.EnsureHelper(); //线程初始化,这个必须要在开始定义.

        CustomTrace.close(true);          //关闭输出。关闭框架输出,如果影响调试。

        TinyPlayerCS pp = new TinyPlayerCS();

        pp.id = 2009;


        client = new Client();

        client.testUint((uint)3312);

        //client.testPlayer.addEventListener("onOpen", onCSOpen);

        Debug.Log("是否解决了?");
        client.onSocketCloseCS = onSocketClose;
        client.onSocketOpenCS  = onSocketOpen;
        client.onSocketErrorCS = onSocketError;
        //  client.connectWithIP("27.102.127.81", 9003); //这里改成你自己的ip
        client.connectWithIP("127.0.0.1", 9003); //这里改成你自己的ip
        //  client.connectWithIP("144.48.4.186", 9003); //这里改成你自己的ip
        client.onGlobalError = onGlobalError;
        // client.testPlayer.dispatchEvent(new CEvent("onOpen"),this );


        self = new PlayerCS(null);
        self.addEvent(); //这里添加倾听器,如果要移除用off
        self.addEventListener(HallEvent.LOGIN, onLogin);

        self.addEventListener(HallEvent.OnReg, onReg);

        self.addEventListener(PlayerEvent.GET_USER_INFO, onGetuserInfo);

        self.addEventListener(PlayerEvent.GET_TEARM_INCOME, onGetIncome);
        self.addEventListener(ShoppingEvent.GET_BUY_LIST, onGetBuyList);
        self.addEventListener(ShoppingEvent.GET_CHARGE_LIST, onGetChargeList);
        self.addEventListener(ShoppingEvent.GET_DRAW_OUT_LIST, onGetDrawOutList);
        self.addEventListener(ShoppingEvent.GET_LAST_CHARGE_TIME, onGetLastChargeTime);
        self.addEventListener(PlayerEvent.STATIC_CHANGE, onStatusChange);
        self.addEventListener(PlayerEvent.ADD_BET, onPlayerAddBet);
        self.addEventListener(RoomEvent.JOIN_ROOM, onJoinRoom);
        self.addEventListener(ShoppingEvent.GET_REATE, onGetRate);
        TestEventDispathFromHaxe();


        //---------------新增-------------------
        hall = new HallCS(); //创建大厅
        hall.addEvent();     //这个一定不能删除。//todo:不能其他人登陆会影响到这里。
        hall.addEventListener(RoomEvent.CREATE_ROOM, onCreateRoom);
        hall.addEventListener(RoomEvent.JOIN_ROOM, onJoinRoom);
        hall.addEventListener(CMDEvent.RESULT, onCMDResult);
    }