コード例 #1
0
 private bool CheckPackets(Dictionary <Socket, byte[]> dictionary, int downloadChannelsCount)
 {
     foreach (var socket in dictionary.Keys)
     {
         var response = dictionary[socket];
         var packets  = PacketUtils.SplitBytes(response, PacketUtils.ServerResponseFileTag());
         if (packets != null && packets.Any())
         {
             var result = packets.FirstOrDefault();
             if (Crc16Utils.CheckCrcCode(result) && PacketUtils.IsPacketComplete(result))
             {
                 var packetNumber = PacketUtils.GetResponsePacketNumber(result);
                 var data         = PacketUtils.GetData(PacketUtils.ServerResponseFileTag(), result);
                 if (!ResultPacketDict.ContainsKey(packetNumber))
                 {
                     ResultPacketDict.Add(packetNumber, data);
                 }
             }
         }
     }
     return(ResultPacketDict.Count == downloadChannelsCount);
 }