Esempio n. 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());
        }
    }
Esempio n. 2
0
    private void _ToConnect()
    {
        string    ip;
        IPAddress ipAddress;

        if (System.Net.IPAddress.TryParse(IPAddress.text, out ipAddress) == false)
        {
            _Error("無效的IP");
            return;
        }

        ip = IPAddress.text;


        int port;

        if (int.TryParse(Port.text, out port) == false)
        {
            _Error("無效的Port");
            return;
        }


        var stage = new ConnectStage(ip, port, _User.Remoting.ConnectProvider);

        stage.SuccessEvent += _ToVerify;
        stage.FailEvent    += _ToConnectFail;

        _Machine.Push(stage);
    }
Esempio n. 3
0
        private void _ToConnect()
        {
            var stage = new ConnectStage(User, _Ip, _Port);

            stage.ConnectResultEvent += stage_ConnectResultEvent;
            _Machine.Push(stage);
        }
Esempio n. 4
0
    private void _ToConnect()
    {
        var stage = new ConnectStage(_Ip, _Port, _User.Remoting.ConnectProvider);

        stage.SuccessEvent += _ToVerify;
        stage.FailEvent    += _ToConnectFail;

        _Machine.Push(stage);
    }
Esempio n. 5
0
 private Value <bool> _ToConnect(System.Net.IPEndPoint ip)
 {
     lock (_Machine)
     {
         var connectValue = new Value <bool>();
         var stage        = new ConnectStage(ip, connectproivder);
         stage.ResultEvent += (result, socket) =>
         {
             _ConnectResult(result, socket);
             connectValue.SetValue(result);
         };
         _Machine.Push(stage);
         return(connectValue);
     }
 }
Esempio n. 6
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);
                }
            }
        }
    }
Esempio n. 7
0
    /* @brief:系统启动注册事件
     *  @return void
     */
    public static void RegistCallback(bool bClear = true)
    {
        ConnectStage.Clear();

        IGameSock iSock = Game.Instance.mGameSock;

        if (iSock != null)
        {
            //连服务器成功后回调
            iSock.RegistCallBack("on_connected", on_connected);
            //连服务器失败后回调
            iSock.RegistCallBack("on_connect_fail", on_connect_fail);
            //网络阻塞
            iSock.RegistCallBack("on_connect_block", on_connect_block);
            //服务器主动关闭回调
            iSock.RegistCallBack("on_close", on_close);
        }
        else
        {
            LogSystem.Log("Error!! ConnectState::RegistCallback iSock is null");
        }
    }
Esempio n. 8
0
    private void _ToConnect()
    {
        string ip;
        IPAddress ipAddress;
        if (System.Net.IPAddress.TryParse(IPAddress.text, out ipAddress) == false)
        {
            _Error("無效的IP");
            return;
        }

        ip = IPAddress.text;

        int port;
        if (int.TryParse(Port.text, out port) == false)
        {
            _Error("無效的Port");
            return;
        }

        var stage = new ConnectStage(ip, port , _User.Remoting.ConnectProvider);

        stage.SuccessEvent += _ToVerify;
        stage.FailEvent += _ToConnectFail;

        _Machine.Push(stage);
    }
Esempio n. 9
0
 private void _ToConnect()
 {
     var stage = new ConnectStage(User,_Ip , _Port);
     stage.ConnectResultEvent += stage_ConnectResultEvent;
     _Machine.Push(stage);
 }
Esempio n. 10
0
 /// <summary>
 /// 响应接收到服务器消息版本信息
 /// </summary>
 /// <param name="args"></param>
 public static void on_server_msg_version(VarList args)
 {
     ConnectStage.mbRecvMsgVersion = true;
     ConnectStage.UserLogin();
 }
Esempio n. 11
0
 /// <summary>
 /// 初始化游戏世界控制
 /// </summary>
 public void InitGameWord()
 {
     ConnectStage.RegistCallback();
     LoginStage.RegistCallback();
     WorldStage.RegistCallback();
 }