public void SendNetData(UInt16 id, object data) { IMessage data1 = data as IMessage; byte[] stream = Protocol3Utility.SerializePackage(data1); mUdpCheckPool.SendCheckPackage(id, stream); }
public void ReceiveCheckPackage(NetPackage mPackage) { PackageCheckResult mPackageCheckResult = Protocol3Utility.getData <PackageCheckResult> (mPackage); UInt16 whoId = (UInt16)(mPackageCheckResult.NWhoOrderId >> 16); UInt16 nOrderId = (UInt16)(mPackageCheckResult.NWhoOrderId & 0x0000FFFF); //DebugSystem.Log ("ServerCheck: nWhoId: " + whoId + " | nOrderId: " + nOrderId); bool bSender = bClient ? whoId == 1 : whoId == 2; if (bSender) { this.mUdpPeer.SendNetPackage(mPackage); CheckPackageInfo mRemovePackage = null; if (mWaitCheckSendDic.TryRemove(nOrderId, out mRemovePackage)) { ObjectPoolManager.Instance.mUdpFixedSizePackagePool.recycle(mRemovePackage.mPackage); mRemovePackage.mPackage = null; mCheckPackagePool.recycle(mRemovePackage); } else { DebugSystem.LogError("Server 已经确认的Send OrderId: " + nOrderId); } } else { CheckPackageInfo mRemovePackage = null; if (mWaitCheckReceiveDic.TryRemove(nOrderId, out mRemovePackage)) { ObjectPoolManager.Instance.mUdpFixedSizePackagePool.recycle(mRemovePackage.mPackage); mRemovePackage.mPackage = null; mCheckPackagePool.recycle(mRemovePackage); } else { DebugSystem.LogError("Server 已经确认的Receive OrderId: " + nOrderId); } } }
public NetUdpFixedSizePackage GetUdpSystemPackage(UInt16 id, object data) { DebugSystem.Assert(id <= 50, "不是 Udp 系统内置命令"); IMessage data1 = data as IMessage; byte[] stream = Protocol3Utility.SerializePackage(data1); var mPackage = ObjectPoolManager.Instance.mUdpFixedSizePackagePool.Pop(); mPackage.nOrderId = 0; mPackage.nGroupCount = 0; mPackage.nPackageId = id; mPackage.Length = stream.Length + ServerConfig.nUdpPackageFixedHeadSize; Array.Copy(stream, 0, mPackage.buffer, ServerConfig.nUdpPackageFixedHeadSize, stream.Length); NetPackageEncryption.Encryption(mPackage); return(mPackage); }
public void ReceiveUdpClientHeart(NetPackage mPackage) { HeartBeat msg = Protocol3Utility.getData <HeartBeat> (mPackage); SendHeartBeat(); }