コード例 #1
0
 /// <summary>
 /// Creates a new NetBlob using the provided BlobFrag as the first
 /// </summary>
 /// <param name="frag">BlobFrag to add initially to this NetBlob</param>
 public NetBlob(BlobFrag frag)
 {
     log.DebugFormat("New NetBlob for ID 0x{0:X4}, Number of Frags: {1}, Queue ID: {2}", frag.BlobSequenceId, frag.NumFrags, frag.QueueID);
     Id        = frag.BlobSequenceId;
     NumFrags  = frag.NumFrags;
     QueueId   = frag.QueueID;
     Fragments = new BlobFrag[frag.NumFrags];
     AddFrag(frag);
 }
コード例 #2
0
 /// <summary>
 /// Adds a new BlobFrag
 /// </summary>
 /// <param name="frag">BlobFrag to add</param>
 /// <returns>Result of the add operation, either indicating an error, Success but still partial, or Success and complete</returns>
 public AddResult AddFrag(BlobFrag frag)
 {
     log.DebugFormat("AddFrag for ID 0x{0:X4}, BlobNum: {1}", Id, frag.BlobNum);
     if (Fragments[frag.BlobNum] != null)
     {
         log.WarnFormat("AddFrag for ID 0x{0:X4}, ErrorFragExists", Id);
         return(AddResult.ErrorFragExists);
     }
     Fragments[frag.BlobNum] = frag;
     fragCount++;
     if (IsComplete)
     {
         log.DebugFormat("AddFrag for ID 0x{0:X4}, SuccessComplete", Id);
         return(AddResult.SuccessComplete);
     }
     else
     {
         log.DebugFormat("AddFrag for ID 0x{0:X4}, SuccessPartial", Id);
         return(AddResult.SuccessPartial);
     }
 }
コード例 #3
0
ファイル: Packet.cs プロジェクト: fartwhif/ACE.Network
        public void Unpack(BinaryReader reader)
        {
            var bytesRemaining = reader.BytesRemaining();

            log.DebugFormat("Unpack bytes: {0}", bytesRemaining);
            log.Assert(bytesRemaining >= PacketHeaderSize, "Packet size too small");
            log.Assert(bytesRemaining <= MaxPacketSize, "Packet size too big");

            SeqID     = reader.ReadUInt32();
            Header    = (PacketHeaderFlags)reader.ReadUInt32();
            Checksum  = reader.ReadUInt32();
            RecId     = reader.ReadUInt16();
            Interval  = reader.ReadUInt16();
            DataLen   = reader.ReadUInt16();
            Iteration = reader.ReadUInt16();

            log.DebugFormat("SeqID: {0}, Header: {1}, Checksum {2}, RecId: {3}, Interval {4}, DataLen: {5}, Iteration: {6}", SeqID, Header, Checksum, RecId, Interval, DataLen, Iteration);

            bytesRemaining = reader.BytesRemaining();
#if NETWORKVALIDATION
            log.Assert(bytesRemaining == DataLen, "Size of reader " + DataLen + " does not equal packet length: " + bytesRemaining);
#endif

            if ((Header & PacketHeaderFlags.ServerSwitch) != 0)
            {
                ServerSwitchData.Unpack(reader);
            }
            if ((Header & PacketHeaderFlags.Referral) != 0)
            {
                ReferralData.Unpack(reader);
            }
            if ((Header & PacketHeaderFlags.NegativeAck) != 0)
            {
                NegativeAckData.Unpack(reader);
            }
            if ((Header & PacketHeaderFlags.EmptyAck) != 0)
            {
                EmptyAckData.Unpack(reader);
            }
            if ((Header & PacketHeaderFlags.PositiveAck) != 0)
            {
                PositiveAckData.Unpack(reader);
            }
            if ((Header & PacketHeaderFlags.LoginRequest) != 0)
            {
                LoginRequestData.Unpack(reader);
            }
            if ((Header & PacketHeaderFlags.ServerSwitchRequest) != 0)
            {
                ServerSwitchRequestData.Unpack(reader);
            }
            if ((Header & PacketHeaderFlags.ConnectRequest) != 0)
            {
                ConnectRequestData.Unpack(reader);
            }
            if ((Header & PacketHeaderFlags.ConnectResponse) != 0)
            {
                ConnectResponseData.Unpack(reader);
            }
            if ((Header & PacketHeaderFlags.NetError) != 0)
            {
                NetErrorData.Unpack(reader);
            }
            if ((Header & PacketHeaderFlags.CloseConnection) != 0)
            {
                CloseConnectionData.Unpack(reader);
            }
            if ((Header & PacketHeaderFlags.CICMDCommand) != 0)
            {
                CicmdData.Unpack(reader);
            }
            if ((Header & PacketHeaderFlags.TimeSync) != 0)
            {
                TimeSyncData.Unpack(reader);
            }
            if ((Header & PacketHeaderFlags.EchoRequest) != 0)
            {
                EchoRequestData.Unpack(reader);
            }
            if ((Header & PacketHeaderFlags.EchoResponse) != 0)
            {
                EchoResponseData.Unpack(reader);
            }
            if ((Header & PacketHeaderFlags.Flow) != 0)
            {
                FlowData.Unpack(reader);
            }
            if ((Header & PacketHeaderFlags.BlobFragments) != 0)
            {
                log.Debug("Reading Blob Fragments");
                Fragments.Clear();
                bytesRemaining = reader.BytesRemaining();
                uint fragNum = 0;
                while (bytesRemaining >= 16)
                {
                    log.DebugFormat("Bytes Remaining: {0}", bytesRemaining);
                    BlobFrag newItem = new BlobFrag(reader);
#if NETWORKDEBUG
                    newItem.NetworkPacketNum   = NetworkPacketNum;
                    newItem.NetworkFragmentNum = ++fragNum;
#endif
                    Fragments.Add(newItem);
                    bytesRemaining = reader.BytesRemaining();
                }
#if NETWORKVALIDATION
                log.Assert(bytesRemaining == 0, "Bytes still remaining in packet: " + bytesRemaining);
#endif
            }
        }