Пример #1
0
    static void OnNetBlockOrClose()
    {
        try
        {
            //Debug.Log("OnNetBlockOrClose");
            gConnectCount            = 0;
            WorldStage.mbReConnected = true;
            //启动断线重连,重新发送登录消息
            Game game = Game.Instance;
            if (game != null)
            {
                game.mGameSock.Disconnect();
                game.mGameSock.InitUserSock();

                ConnectStage.RegistCallback(false);
                LoginStage.RegistCallback(false);
                WorldStage.RegistCallback(false);
                ///第一次连接失败,添加心跳开始持续一分钟连接12次,依然没有连上认为断开
                ConnectStage.ConnecToMember(mstrServer, miPort, mstrUser, mstrPsd, mstrValidateString, 2);
                //Debug.Log("第一次重连");
                TimerManager.AddTimerRepeat("OnNetBlockTimer", 5.0f, OnNetBlockTimer);
                LogSystem.LogWarning("First block connect try");
                //SystemWaitPanel.Start(99999999);
            }
        }
        catch (System.Exception ex)
        {
            LogSystem.LogError("Game::OnNetBlockOrClose:", ex.ToString());
        }
    }
Пример #2
0
    static void OnNetBlockTimer()
    {
        //启动断线重连,重新发送登录消息
        Game game = Game.Instance;

        if (game != null)
        {
            game.mGameSock.Disconnect();
            game.mGameSock.InitUserSock();

            ConnectStage.RegistCallback(false);
            LoginStage.RegistCallback(false);
            WorldStage.RegistCallback(false);
            //Debug.Log("第二次重连");
            ConnectStage.ConnecToMember(mstrServer, miPort, mstrUser, mstrPsd, mstrValidateString, 2);

            gConnectCount++;
            LogSystem.LogWarning(gConnectCount + ": block connect try");
            if (gConnectCount > 4)
            {
                mbNeedReConnect = false;
                TimerManager.Destroy("OnNetBlockTimer");
                ///显示网络已经断线
                string strHeader  = TextManager.Instance.GetString("UI00031");
                string strContext = TextManager.Instance.GetString("NetClose");
                if (!string.IsNullOrEmpty(strHeader) && !string.IsNullOrEmpty(strContext))
                {
//                     if (GUIManager.HasView<SystemPrompt>())
//                     {
//                         GUIManager.HideView<SystemPrompt>("SystemPrompt");
//                     }
//                     PromptType pt = PoolManager.PopObject<PromptType>(PoolManager.PoolKey.Object_PromptType);
//                     pt.layer = 5;
//                     pt.title = strHeader;
//                     pt.content = strContext;
//                     pt.style = PromptType.Style.OK;
//                     pt.callback_ok = OnConnectSecondTime;
//                     GUIManager.ShowView<SystemPrompt>(pt);
                }
            }
        }
    }
Пример #3
0
 /// <summary>
 /// 初始化游戏世界控制
 /// </summary>
 public void InitGameWord()
 {
     ConnectStage.RegistCallback();
     LoginStage.RegistCallback();
     WorldStage.RegistCallback();
 }