Exemple #1
0
    /// <summary>
    /// 发送登录消息
    /// </summary>
    /// <param name="loginMsg"></param>
    public void SendCSLoginMsg(ref DGPKG loginMsg, CSMsgDelegate callback, bool bLockScreen = false)
    {
        if (mGameServerHandler != null && mGameServerHandler.IsConnected())
        {
            if (bLockScreen)
            {
                //UI3System.lockScreen(902/*" 正在连接..."*/, 10.0f, () => {
                //        UISystemTip.ShowTip(901/*"网络已断开,点击重新连接"*/, ReConnect);
                //    });
            }

            MsgInfo msginfo = SetMsgInfo(loginMsg, callback);
            Send(ref loginMsg);
            mCSMsgAlreadySentList.Add(msginfo);
        }
        else if (LoginMgr.Instance.m_bNeedRecon)
        {
            // Modified by [email protected]
            // 目前在已上线版本中发现一个偶现但多次出现的bug:
            // CS.ReconnectReq有一定机率会被扔到集合m_lstBeforeReconnNotSendMsg当中,原因不明。
            // 所以,为避免这个情况再发生,这里作一下过滤
            if (loginMsg.header.msg_full_name != "CS.ReconnectReq")
            {
                MsgInfo msg = new MsgInfo(loginMsg, callback);
                m_lstBeforeReconnNotSendMsg.Add(msg);
            }

            //UISystemTip.ShowTip(901/*"网络已断开,点击重新连接"*/, ReConnect);
        }
    }
 public void UnRegistHandle(string sFullName, CSMsgDelegate callback)
 {
     if (m_dicHandle.ContainsKey(sFullName))
     {
         m_dicHandle.Remove(sFullName);
     }
 }
Exemple #3
0
 public void Set(DGPKG msg, CSMsgDelegate callback)
 {
     mMsg      = msg;
     mCallBack = callback;
     mValid    = true;
     mSentTime = UnityEngine.Time.realtimeSinceStartup;
 }
 public void RegistHandle(string sFullName, CSMsgDelegate oHandle)
 {
     if (m_dicHandle.ContainsKey(sFullName))
     {
         return;
     }
     m_dicHandle.Add(sFullName, oHandle);
 }
        public void HandleMsg(DGPKG msg)
        {
            CSMsgDelegate handle = null;

            if (m_dicHandle.TryGetValue(msg.header.msg_full_name, out handle))
            {
                handle(CSMsgResult.NoError, msg);
            }
        }
Exemple #6
0
    /// <summary>
    /// 发送重连请求
    /// </summary>
    void ReConnReq(CSMsgDelegate callback)
    {
        // 保证加密解密开关是关闭的
        LoginMgr.Instance.ToggleGameServerMsgFilter(false);

        var Req = new ReconnectReq();

        Req.uid   = s_uid;
        Req.gcode = gcode;
        DGPKG msg = ProtocolDGlUtility.BuildDGMsg(Req);

        Network.Instance.SendCSLoginMsg(ref msg, callback);
    }
Exemple #7
0
    private MsgInfo SetMsgInfo(DGPKG msg, CSMsgDelegate callback)
    {
        int i = (int)msg.header.seq % kCSMsgCallArrayLength;

        if (mMsgInfoArray[i] == null)
        {
            mMsgInfoArray[i] = new MsgInfo(msg, callback);
        }
        else
        {
            mMsgInfoArray[i].Set(msg, callback);
        }
        return(mMsgInfoArray[i]);
    }
Exemple #8
0
    /// <summary>
    /// 向游戏服务器发送数据包
    /// </summary>
    /// <param name="msg"></param>
    /// <returns></returns>
    private void SendCSMsg(ref DGPKG msg, CSMsgDelegate callback)
    {
        MsgInfo msginfo = SetMsgInfo(msg, callback);

        mCSMsgWaitSendList.Add(msginfo);
    }