Exemple #1
0
        public void ProcessRequest(Stream input, Stream output)
        {
            TTransport transport = new TStreamTransport(input, output);

            TProtocol inputProtocol  = null;
            TProtocol outputProtocol = null;

            try
            {
                inputProtocol  = inputProtocolFactory.GetProtocol(transport);
                outputProtocol = outputProtocolFactory.GetProtocol(transport);

                while (processor.Process(inputProtocol, outputProtocol))
                {
                }
            }
            catch (TTransportException)
            {
                // Client died, just move on
            }
            catch (TApplicationException tx)
            {
                Console.Error.Write(tx);
            }
            catch (Exception x)
            {
                Console.Error.Write(x);
            }

            transport.Close();
        }
Exemple #2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType     = "application/x-thrift";
            context.Response.ContentEncoding = System.Text.Encoding.UTF8;

            TTransport transport = new TStreamTransport(context.Request.InputStream, context.Response.OutputStream);

            TProtocol inputProtocol  = null;
            TProtocol outputProtocol = null;

            try
            {
                inputProtocol  = inputProtocolFactory.GetProtocol(transport);
                outputProtocol = outputProtocolFactory.GetProtocol(transport);

                while (processor.Process(inputProtocol, outputProtocol))
                {
                }
            }
            catch (TTransportException)
            {
                // Client died, just move on
            }
            catch (TApplicationException tx)
            {
                Console.Error.Write(tx);
            }
            catch (Exception x)
            {
                Console.Error.Write(x);
            }

            transport.Close();
        }
Exemple #3
0
        public void ProcessRequest(Stream input, Stream output)
        {
            TTransport transport = new TStreamTransport(input,output);

            try
            {
                var inputProtocol = inputProtocolFactory.GetProtocol(transport);
                var outputProtocol = outputProtocolFactory.GetProtocol(transport);

                while (processor.Process(inputProtocol, outputProtocol))
                {
                }
            }
            catch (TTransportException)
            {
                // Client died, just move on
            }
            finally
            {
                transport.Close();
            }
        }
Exemple #4
0
        public void ProcessRequest(Stream input, Stream output)
        {
            TTransport transport = new TStreamTransport(input, output);

            try
            {
                var inputProtocol  = inputProtocolFactory.GetProtocol(transport);
                var outputProtocol = outputProtocolFactory.GetProtocol(transport);

                while (processor.Process(inputProtocol, outputProtocol))
                {
                }
            }
            catch (TTransportException)
            {
                // Client died, just move on
            }
            finally
            {
                transport.Close();
            }
        }
        public override async Task ProcessRequestAsync(HttpContext context)
        {
            var transport = new TStreamTransport(context.Request.InputStream, context.Response.OutputStream);

            try
            {
                var input  = _inputProtocolFactory.GetProtocol(transport);
                var output = _outputProtocolFactory.GetProtocol(transport);

                while (await _processor.ProcessAsync(input, output))
                {
                }
            }
            catch (TTransportException)
            {
                // Client died, just move on
            }
            finally
            {
                transport.Close();
            }
        }
        public override async Task ProcessRequestAsync(HttpContext context)
        {
            var transport = new TStreamTransport(context.Request.InputStream, context.Response.OutputStream);

            try
            {
                var input = _inputProtocolFactory.GetProtocol(transport);
                var output = _outputProtocolFactory.GetProtocol(transport);

                while (await _processor.ProcessAsync(input, output))
                {
                }
            }
            catch (TTransportException)
            {
                // Client died, just move on
            }
            finally
            {
                transport.Close();
            }
        }
        public void ProcessRequest(Stream input, Stream output)
        {
            TTransport transport = new TStreamTransport(input, output);

            TProtocol inputProtocol = null;
            TProtocol outputProtocol = null;

            try
            {
                inputProtocol = inputProtocolFactory.GetProtocol(transport);
                outputProtocol = outputProtocolFactory.GetProtocol(transport);

                while (processor.Process(inputProtocol, outputProtocol)) { }
            }
            catch (TTransportException exp)
            {
                //throw exp;
                // Client died, just move on
            }
            catch (TApplicationException tx)
            {
                Console.Error.Write(tx);
            }
            catch (Exception x)
            {
                Console.Error.Write(x);
            }

            transport.Close();
        }
Exemple #8
0
 public override void Close()
 {
     CloseBuffers();
     transport.Close();
 }
        public async Task Run(string sendAddress, string sendToken)
        {
            try
            {
                var relayClient = new RelayClient(sendAddress, TokenProvider.CreateSharedAccessSignatureTokenProvider(sendToken));
                var relayConnection = relayClient.Connect();

                TTransport transport = new TStreamTransport(relayConnection, relayConnection);
                TProtocol protocol = new TBinaryProtocol(transport);
                Calculator.Client client = new Calculator.Client(protocol);

                transport.Open();
                try
                {
                    client.ping();
                    Console.WriteLine("ping()");

                    int sum = client.add(1, 1);
                    Console.WriteLine("1+1={0}", sum);

                    Work work = new Work();

                    work.Op = Operation.DIVIDE;
                    work.Num1 = 1;
                    work.Num2 = 0;
                    try
                    {
                        int quotient = client.calculate(1, work);
                        Console.WriteLine("Whoa we can divide by 0");
                    }
                    catch (InvalidOperation io)
                    {
                        Console.WriteLine("Invalid operation: " + io.Why);
                    }

                    work.Op = Operation.SUBTRACT;
                    work.Num1 = 15;
                    work.Num2 = 10;
                    try
                    {
                        int diff = client.calculate(1, work);
                        Console.WriteLine("15-10={0}", diff);
                    }
                    catch (InvalidOperation io)
                    {
                        Console.WriteLine("Invalid operation: " + io.Why);
                    }

                    SharedStruct log = client.getStruct(1);
                    Console.WriteLine("Check log: {0}", log.Value);

                }
                finally
                {
                    transport.Close();
                }
            }
            catch (TApplicationException x)
            {
                Console.WriteLine(x.StackTrace);
            }

        }