예제 #1
0
    /// <summary>
    /// 有重连结果后 调用
    /// </summary>
    /// <returns>反回重连次数是否已用完</returns>
    private void ConnRespResult(NetMsg netMsg)
    {
        if (netMsg.MsgType != NetMsgType.Error &&
            netMsg.MsgType != NetMsgType.Disconnect &&
            netMsg.MsgType != NetMsgType.Connect)
        {
            return;
        }
        _networkAdapter.DelNetRespEvent(ConnRespResult);

        if (netMsg.MsgType == NetMsgType.Connect)
        {
            _curReConnNum       = 0;
            _reConnectFail      = false;
            _isStartReConnect   = false;
            isStartReconnTiming = false;
            //Odin.Log.Info("ReConnect Succ");
            return;
        }

        //Odin.Log.Error("ReConnect:{0} Fail", _curReConnNum);

        _curReConnNum++;
        if (_curReConnNum < _maxReConnNum)
        {
            //重连失败开启重连计时
            isStartReconnTiming = true;
            return;
        }

        _curReConnNum     = 0;
        _isStartReConnect = false;

        _reConnectFail = true;
        _reConnectFailCb();
    }