예제 #1
0
        public void BeginRead(ConnectionContextTPL connectionContext)
        {
            InputStreamContext ctx = new InputStreamContext(connectionContext, bufferSize);

            Task<int>.Factory.FromAsync<byte[], int, int>(ctx.ConnectionContext.ClientStream.BeginRead,
                ctx.ConnectionContext.ClientStream.EndRead, ctx.Header, 0, sizeof(long), ctx).ContinueWith(BeginReadCallback);
        }
예제 #2
0
 private void ProcessRequest(InputStreamContext ctx)
 {
     lock (ctx.ConnectionContext)
         ctx.ConnectionContext.InputQueue.Enqueue(ctx);
     BeginRead(ctx.ConnectionContext);
 }
예제 #3
0
 private void ReadChunk(InputStreamContext ctx)
 {
     int bytesToRead = ctx.RemainingBytes > ctx.Buffer.Length ? ctx.Buffer.Length : (int)ctx.RemainingBytes;
     Task<int>.Factory.FromAsync<byte[], int, int>(ctx.ConnectionContext.ClientStream.BeginRead,
         ctx.ConnectionContext.ClientStream.EndRead, ctx.Buffer, 0, bytesToRead, ctx).ContinueWith(BeginReadCallback);
 }
예제 #4
0
 private void EnqueueEmptyHeader(InputStreamContext ctx)
 {
     Log.LogMessage("Writing empty header");
     InputStreamContext inputContext = new InputStreamContext(ctx.ConnectionContext, bufferSize);
     inputContext.EmptyResponse = true;
     ctx.ConnectionContext.InputQueue.Enqueue(inputContext);
 }