Example #1
0
        public void TestMethod_Log()
        {
            Config.DefaultConfigOnWindows();
            Config.IsAutoHeartbeat = false;
            DNClient.GetInst().isDebugLog        = true;
            LogFile.GetInst().isImmediatelyFlush = true;
            DxDebug.LogWarning("123");
            DxDebug.LogError("123");

            DNClient.GetInst().CloseImmediate();
            DNServer.GetInst().Close();
            LogFile.GetInst().Close();
        }
Example #2
0
    /// <summary>
    /// 自动重连处理,在update中调用
    /// </summary>
    private void AutoReConnect()
    {
        try
        {
            _sumDeltaTime_ARC += Time.deltaTime;
            if (_sumDeltaTime_ARC >= 0.2f) //0.2秒的定时,每一秒都会进入
            {
                _sumDeltaTime_ARC = 0;
                //检测到了断线
                if (isAutoReConnect == true && DNClient.GetInstance().IsConnected == false && DNClient.GetInstance().IsConnecting == false)
                {
                    DxDebug.LogWarning("NetPoll.AutoReConnect():当前已经断线!开始自动重连...");
                    _isConnectionBreak = true;//标记当前已经断线
                    if (EventConnectionBreak != null)
                    {
                        EventConnectionBreak();//执行事件当前已经断线
                    }
                    //连一下服务器算了
                    DNClient.GetInstance().Connect(IP, prot); //ywz:10.1.32.81 "127.0.0.1"
                }

                //检测到了自动重连成功
                if (_isConnectionBreak == true && DNClient.GetInstance().IsConnected == true)//此时已经连接成功
                {
                    DxDebug.LogWarning("NetPoll.AutoReConnect():当前已经自动重连成功!");
                    _isConnectionBreak = false;//标记当前不再断线
                    if (EventReconnectsucceed != null)
                    {
                        EventReconnectsucceed();//执行事件当前已经重连成功
                    }
                }
            }
        }
        catch (Exception e)
        {
            DxDebug.LogWarning("NetPoll.AutoReConnect():执行AutoReConnect()异常!" + e.Message);
        }
    }