private void OnRecvTimeSyn(Packet packet)
 {
     #if DEBUG
     Logs.Info("Recived TimeSyn:" + packet.PacketID.ToString());
     #endif
     TimeSynPacket p = packet as TimeSynPacket;
     m_Ping = (int)(m_SynTimer.ElapsedMilliseconds - p.ClinetTimeStamp);
     m_TimeSpanWithServer = (long)((DateTime.FromBinary(p.ServerTimeStamp) - DateTime.Now).TotalMilliseconds);
     //����,��Ϊֱ�������ﴦ����
     this.PacketCreatorMgr_Recived.GetPacketCreator(TimeSynPacket._PacketID).RecylePacket(p);
 }
예제 #2
0
        protected override void HandleReceviedPackets(NetClientBase client, NetIOCPClient.NetWork.Packet recivedPacket)
        {
            //关联包处理
            ProfInstance pi = Profile.StartProf();

            //ToDo:读取内容

            if (PacketHandles[recivedPacket.PacketID] != null)
            {
                PacketHandles[recivedPacket.PacketID](0L, recivedPacket);
            }
            else
            {
                //Debug.Assert(false, p.ToString() + "没有相应的解析委托");
                Console.WriteLine("包" + recivedPacket.PacketID + "没有相应的解析委托");
            }
            pi.EndProf(recivedPacket.ToString(), 1f);
        }
예제 #3
0
 /// <summary>
 /// 创建的 与回收的 packetid必须一样,通过ID来关联创建器与 packet对象
 /// 自动回收Packet.Buffer以及清理packet的内部关联数据
 /// </summary>
 /// <param name="p"></param>
 public abstract void RecylePacket(Packet p);
예제 #4
0
 public PacketWriteException(Packet p, PacketErrorLevel errLevel, Exception inner)
     : base("写Packet错误", inner)
 {
     ErrPacket = p;
     ErrLevel = errLevel;
 }
예제 #5
0
 public PacketReadException(Packet p, PacketErrorLevel errLevel, Exception inner)
     : base("读packet错误", inner)
 {
     ErrPacket = p;
     ErrLevel = errLevel;
 }
예제 #6
0
 static void nc_OnSend(NetClientBase sender, Packet p)
 {
     Console.WriteLine("send:"+(p==null?"byte[]":p.ToString()));
 }
예제 #7
0
 static void nc_OnRecvData(NetClientBase sender, Packet p)
 {
     Console.WriteLine("recived packet:" + p.ToString());
 }
예제 #8
0
 public override void RecylePacket(Packet p)
 {
     _initPacketPool();
     p.Buffer.DecrementUsage();
     if (p.Buffer.Uses == 0) {
         p.Buffer = null;
     }
     p.ClearContent();
     _packetPool.ReleaseContent(p as CustomPacket);
 }
예제 #9
0
 public override void RecylePacket(Packet p)
 {
     _initPacketPool();
     System.Diagnostics.Debug.Assert(p.Buffer.Uses == 1);
     p.Buffer.DecrementUsage();
     if (p.Buffer.Uses == 0) {
         p.Buffer = null;
     }
     p.ClearContent();//防止内存溢出
     _packetPool.ReleaseContent(p as TimeSynPacket);
 }