public void HandleInboundMultiPartChunk(MultiPartChunkDto chunk) {
         bool isAdded = false;
         ChunkReassemblyContext addedChunkReassemblyContext = null;
         var chunkReassemblyContext = chunkReassemblerContextsByMessageId.GetOrAdd(
            chunk.MultiPartMessageId,
            add => {
//               logger.Info(Thread.CurrentThread.ManagedThreadId + ": " + "NEW " + chunk.MultiPartMessageId + " " + this.GetHashCode());

               isAdded = true;
               return addedChunkReassemblyContext = new ChunkReassemblyContext(chunk.ChunkCount);
            });

//         if (isAdded) {
//            logger.Info(Thread.CurrentThread.ManagedThreadId + ": " + chunkReassemblyContext.GetHashCode() + " " + new ChunkReassemblyContext(0).GetHashCode() + "");
//         }

         if (chunkReassemblyContext == addedChunkReassemblyContext) {
            Go(async () => {
               await Task.Delay(kSomethingExpiration).ConfigureAwait(false);

               RemoveAssemblerFromCache(chunk.MultiPartMessageId);
            });
         }

         var completedChunks = chunkReassemblyContext.AddChunk(chunk);
         if (completedChunks != null) {
            ReassembleChunksAndDispatch(completedChunks);
         }
      }
示例#2
0
        public void HandleInboundMultiPartChunk(MultiPartChunkDto chunk)
        {
            bool isAdded = false;
            ChunkReassemblyContext addedChunkReassemblyContext = null;
            var chunkReassemblyContext = chunkReassemblerContextsByMessageId.GetOrAdd(
                chunk.MultiPartMessageId,
                add => {
//               logger.Info(Thread.CurrentThread.ManagedThreadId + ": " + "NEW " + chunk.MultiPartMessageId + " " + this.GetHashCode());

                isAdded = true;
                return(addedChunkReassemblyContext = new ChunkReassemblyContext(chunk.ChunkCount));
            });

//         if (isAdded) {
//            logger.Info(Thread.CurrentThread.ManagedThreadId + ": " + chunkReassemblyContext.GetHashCode() + " " + new ChunkReassemblyContext(0).GetHashCode() + "");
//         }

            if (chunkReassemblyContext == addedChunkReassemblyContext)
            {
                Go(async() => {
                    await Task.Delay(kSomethingExpiration).ConfigureAwait(false);

                    RemoveAssemblerFromCache(chunk.MultiPartMessageId);
                });
            }

            var completedChunks = chunkReassemblyContext.AddChunk(chunk);

            if (completedChunks != null)
            {
                ReassembleChunksAndDispatch(completedChunks);
            }
        }