示例#1
0
        public StreamingResponse <TResponse> SendRequest(TRequest message)
        {
            StreamingRequest <TRequest> request = new StreamingRequest <TRequest> {
                Message = message
            };

            SendRequest(request);
            return(ReceiveResponse <StreamingResponse <TResponse> >(NetworkStream));
        }
示例#2
0
        protected internal override void ReadRequest(TcpClient client)
        {
            while (client.Connected)
            {
                try
                {
                    GetStreamData(client, out NetworkStream stream, out byte[] requestData);

                    StreamingRequest <TRequest> request = requestData.FromBinaryBytes <StreamingRequest <TRequest> >();
                    StreamingContext <TRequest> ctx     = new StreamingContext <TRequest>
                    {
                        Request        = request,
                        ResponseStream = stream,
                        Encoding       = Encoding
                    };
                    TResponse response = ProcessRequest(ctx);
                    WriteResponse(ctx, response);
                }
                catch (Exception ex)
                {
                    Logger.AddEntry("Error reading request: {0}", ex, ex.Message);
                }
            }
        }