Esempio n. 1
0
        private void ReceiveCheckPackage(NetPackage mPackage)
        {
            PackageCheckResult mPackageCheckResult = Protocol3Utility.getData <PackageCheckResult> (mPackage);
            UInt16             whoId    = (UInt16)(mPackageCheckResult.NWhoOrderId >> 16);
            UInt16             nOrderId = (UInt16)(mPackageCheckResult.NWhoOrderId & 0x0000FFFF);

            //DebugSystem.Log ("Client Check: nWhoId: " + whoId + " | nOrderId: " + nOrderId);

            bool bSender = bClient ? whoId == 1 : whoId == 2;

            if (bSender)
            {
                this.mUdpPeer.SendNetPackage(mPackage);

                CheckPackageInfo mRemovePackage = null;
                if (mWaitCheckSendDic.TryGetValue(nOrderId, out mRemovePackage))
                {
                    ObjectPoolManager.Instance.mUdpFixedSizePackagePool.recycle(mRemovePackage.mPackage);
                    mRemovePackage.mPackage = null;

                    mWaitCheckSendDic.Remove(nOrderId);
                    mCheckPackagePool.recycle(mRemovePackage);
                }
                else
                {
                    DebugSystem.LogError("Client 我已经收到 Send确认包了: " + nOrderId);
                }
            }
            else
            {
                CheckPackageInfo mRemovePackage = null;
                if (mWaitCheckReceiveDic.TryGetValue(nOrderId, out mRemovePackage))
                {
                    ObjectPoolManager.Instance.mUdpFixedSizePackagePool.recycle(mRemovePackage.mPackage);
                    mRemovePackage.mPackage = null;

                    mWaitCheckReceiveDic.Remove(nOrderId);
                    mCheckPackagePool.recycle(mRemovePackage);
                }
                else
                {
                    DebugSystem.LogError("Client 我已经收到Receive确认包了: " + nOrderId);
                }
            }
        }
        public void ReceiveCheckPackage(NetUdpFixedSizePackage mPackage)
        {
            //DebugSystem.Log ("Server ReceiveInfo: " + mPackage.nOrderId + " | " + mPackage.nGroupCount + " | " + mPackage.Length);

            if (ServerConfig.bNeedCheckPackage)
            {
                PackageCheckResult mResult = new PackageCheckResult();
                if (bClient)
                {
                    mResult.NWhoOrderId = (UInt32)(2 << 16 | mPackage.nOrderId);
                }
                else
                {
                    mResult.NWhoOrderId = (UInt32)(1 << 16 | mPackage.nOrderId);
                }
                NetUdpFixedSizePackage mCheckResultPackage = mUdpPeer.GetUdpSystemPackage(UdpNetCommand.COMMAND_PACKAGECHECK, mResult);

                CheckPackageInfo mCheckInfo = mCheckPackagePool.Pop();
                mCheckInfo.nReSendCount = 0;
                mCheckInfo.mPackage     = mCheckResultPackage;
                mCheckInfo.mTimer.restart();
                mWaitCheckReceiveDic.TryAdd(mPackage.nOrderId, mCheckInfo);

                mUdpPeer.SendNetPackage(mCheckResultPackage);

                CheckReceivePackageLoss(mPackage);
            }
            else
            {
#if !Test
                if (ServerConfig.IsLocalAreaNetWork)
                {
                    if (nCurrentWaitReceiveOrderId != mPackage.nOrderId)
                    {
                        DebugSystem.LogError("服务器端 丢包: " + mUdpPeer.getPort() + " | " + nCurrentWaitReceiveOrderId);
                    }
                    else
                    {
                        AddReceivePackageOrderId();
                    }
                }
#endif
                CheckCombinePackage(mPackage);
            }
        }
Esempio n. 3
0
        public void ReceiveCheckPackage(NetUdpFixedSizePackage mReceiveLogicPackage)
        {
            if (ClientConfig.bNeedCheckPackage)
            {
                UInt16             nOrderId = mReceiveLogicPackage.nOrderId;
                PackageCheckResult mResult  = new PackageCheckResult();
                if (bClient)
                {
                    mResult.NWhoOrderId = (UInt32)(2 << 16 | nOrderId);
                }
                else
                {
                    mResult.NWhoOrderId = (UInt32)(1 << 16 | nOrderId);
                }

                NetUdpFixedSizePackage mCheckResultPackage = mUdpPeer.GetUdpSystemPackage(UdpNetCommand.COMMAND_PACKAGECHECK, mResult);

                CheckPackageInfo mCheckInfo = mCheckPackagePool.Pop();
                mCheckInfo.nReSendCount = 0;
                mCheckInfo.mPackage     = mCheckResultPackage;
                mCheckInfo.mTimer.restart();

                if (!mWaitCheckReceiveDic.ContainsKey(nOrderId))
                {
                    mWaitCheckReceiveDic.Add(nOrderId, mCheckInfo);
                }

                mUdpPeer.SendNetPackage(mCheckResultPackage);

                CheckReceivePackageLoss(mReceiveLogicPackage);
            }
            else
            {
                CheckCombinePackage(mReceiveLogicPackage);
            }
        }