public OutputStreamContext(ConnectionContext connectionContext)
 {
     this.connectionContext = connectionContext;
 }
 public void BeginRead(ConnectionContext connectionContext)
 {
     InputStreamContext ctx = new InputStreamContext(connectionContext, bufferSize);
     ctx.ConnectionContext.ClientStream.BeginRead(ctx.Header, 0, sizeof(long), BeginReadCallback, ctx);
 }
        private void BeginAcceptSocketCallback(IAsyncResult result)
        {
            Log.LogMessage("Received socket connection");

            TcpListener tcpListener = (TcpListener)result.AsyncState;
            TcpClient tcpClient = tcpListener.EndAcceptTcpClient(result);
            NetworkStream clientStream = tcpClient.GetStream();

            ConnectionContext ctx = new ConnectionContext(clientStream, ConnString, this);
            ctx.StartProcessingInputQueue();
            BeginRead(ctx);

            tcpListener.BeginAcceptTcpClient(BeginAcceptSocketCallback, tcpListener);
        }
 public InputStreamContext(ConnectionContext connectionContext, int bufferSize)
 {
     this.connectionContext = connectionContext;
     this.buffer = new byte[bufferSize];
 }