Example #1
0
    //强制暂停时,事件
    void pauseTime()
    {
        if (Application.isEditor)
        {
            return;
        }

        LevelTimer = DateTime.Now;

        if (MahjongGame_AH.GameData.Instance)
        {
            MahjongGame_AH.Network.Message.NetMsg.ClientEscapeReq msg = new MahjongGame_AH.Network.Message.NetMsg.ClientEscapeReq();
            msg.iUserId  = GameData.Instance.PlayerNodeDef.iUserId;
            msg.byEscape = 1;
            Debug.LogError("强制暂停时发送离线消息");
            SendEscapeReq(msg);
        }
    }
Example #2
0
    //“启动”手机时,事件
    void resumeList()
    {
        if (Application.isEditor || LevelTimer.Year == 1 || !MahjongCommonMethod.Instance.isFinshSceneLoad)
        {
            return;
        }

        //大厅
        if (MahjongLobby_AH.GameData.Instance)
        {
            //如果玩家断开连接
            if (!MahjongCommonMethod.Instance.isStartInit_Lobby && (MahjongCommonMethod.Instance.DateTimeToUnixTimestamp(DateTime.Now) - MahjongCommonMethod.Instance.DateTimeToUnixTimestamp(LevelTimer) > 300 || !MahjongLobby_AH.Network.NetworkMgr.Instance.LobbyServer.Connected))
            {
                MahjongCommonMethod.Instance.isStartInit_Lobby = true;
                MahjongCommonMethod.isAuthenSuccessInLobby     = true;
                LevelTimer = DateTime.Now;
                if (MahjongCommonMethod.Instance.DateTimeToUnixTimestamp(DateTime.Now) - MahjongCommonMethod.Instance.DateTimeToUnixTimestamp(LevelTimer) > 300 && !MahjongLobby_AH.Network.NetworkMgr.Instance.LobbyServer.Connected)
                {
                    MahjongLobby_AH.SDKManager.Instance.gameObject.GetComponent <CameControler>().PostMsg("loading", "正在加载大厅资源,请稍候...");
                }

                //检查网络情况,如果网络正常则关闭,并重连服务器,都则不会关闭该面板
                if (MahjongCommonMethod.Instance.NetWorkStatus() > 0)
                {
                    MahjongLobby_AH.Network.NetworkMgr.Instance.LobbyGateway.tryCount = 0;
                    //重新连接
                    MahjongCommonMethod.Instance.InitScene();
                }
            }

            //如果预约时间为0,请求开放回应,刷新界面
            if (MahjongLobby_AH.GameData.Instance.ParlorShowPanelData.isShowOrderTimePanel)
            {
                MahjongLobby_AH.GameData.Instance.ParlorShowPanelData.iUpdateOrderTimer = 1;
                MahjongLobby_AH.Network.Message.NetMsg.ClientMyRoomInfoReq myroominfo = new MahjongLobby_AH.Network.Message.NetMsg.ClientMyRoomInfoReq();
                myroominfo.iUserId = MahjongLobby_AH.GameData.Instance.PlayerNodeDef.iUserId;
                MahjongLobby_AH.Network.NetworkMgr.Instance.LobbyServer.SendMyRoomInfoReq(myroominfo);
            }
        }

        isChangeFromTable = true;
        //如果玩家在游戏,断开连接之后,从后台回来 直接重新连接
        if (MahjongGame_AH.GameData.Instance)
        {
            Debug.LogError("断开连接之后,从后台回来 直接重新连接======================0");
            if (GameData.Instance.PlayerPlayingPanelData.isGameEnd)
            {
                return;
            }

            //如果时间大于300s,或者已经断开连接
            if (!MahjongCommonMethod.Instance.isStartInit_Game && (MahjongCommonMethod.Instance.DateTimeToUnixTimestamp(DateTime.Now) - MahjongCommonMethod.Instance.DateTimeToUnixTimestamp(LevelTimer) > 300 || !MahjongGame_AH.Network.NetworkMgr.Instance.GameServer.Connected))
            {
                MahjongCommonMethod.Instance.isStartInit_Game = true;
                MahjongGame_AH.Network.NetworkMgr.Instance.GameServer.tryCount = 0;
                ////清空消息队列
                //MahjongGame_AH.Network.NetworkMgr.Instance.GameServer.NetClient.m_client.list = new ArrayList();

                Debug.LogError("断开连接之后,从后台回来 直接重新连接======================2");
                LevelTimer = DateTime.Now;
                MahjongLobby_AH.SDKManager.Instance.gameObject.GetComponent <CameControler>().PostMsg("loading", "正在加载游戏资源,请稍候...");
                if (MahjongGame_AH.GameData.Instance.PlayerPlayingPanelData.isPanelShow_Playing)
                {
                    UIMainView.Instance.disConnect.RecoverGameScene(2);
                }
                else
                {
                    UIMainView.Instance.disConnect.RecoverGameScene(1);
                }
            }
            else
            {
                MahjongGame_AH.Network.Message.NetMsg.ClientEscapeReq msg = new MahjongGame_AH.Network.Message.NetMsg.ClientEscapeReq();
                msg.iUserId  = GameData.Instance.PlayerNodeDef.iUserId;
                msg.byEscape = 0;
                Debug.LogError("“启动”手机时发送离线消息");
                if (GameData.Instance.PlayerPlayingPanelData.isPanelShow_Playing)
                {
                    JPush.JPushBinding.StopPush();
                }
                NetworkMgr.Instance.GameServer.SendEscapeReq(msg);
            }
        }

        if (MahjongGame_AH.UIMainView.Instance != null && MahjongGame_AH.UIMainView.Instance.PlayerPlayingPanel != null && MahjongGame_AH.UIMainView.Instance.PlayerPlayingPanel.m_isLost60Scend)
        {
            NetMsg.ClientReadyTimeReqDef msg = new NetMsg.ClientReadyTimeReqDef();
            msg.iUserId   = GameData.Instance.PlayerNodeDef.iUserId;
            msg.wTableNum = (byte)MahjongCommonMethod.Instance.iTableNum;
            MahjongGame_AH.Network.NetworkMgr.Instance.GameServer.SendClientReadyTimeReqDef(msg);
        }
    }