Exemple #1
0
        public async Task Run(string listenAddress, string listenToken)
        {
            try
            {
                CalculatorHandler    handler   = new CalculatorHandler();
                Calculator.Processor processor = new Calculator.Processor(handler);

                TServerTransport serverTransport = new RelayListenerServerTransport(
                    new RelayListener(listenAddress,
                                      TokenProvider.CreateSharedAccessSignatureTokenProvider(listenToken),
                                      RelayAddressType.Configured));

                TServer server = new TSimpleServer(processor, serverTransport);

                // Use this for a multithreaded server
                // server = new TThreadPoolServer(processor, serverTransport);

                Console.WriteLine("Starting the server...");
                server.Serve();
            }
            catch (Exception x)
            {
                Console.WriteLine(x.StackTrace);
            }
            Console.WriteLine("done.");
        }
Exemple #2
0
        public static void Main()
        {
            try
            {
                CalculatorHandler    handler         = new CalculatorHandler();
                Calculator.Processor processor       = new Calculator.Processor(handler);
                TServerTransport     serverTransport = new TServerSocket(9090);
                TServer server = new TSimpleServer(processor, serverTransport);

                // Use this for a multithreaded server
                // server = new TThreadPoolServer(processor, serverTransport);

                Console.WriteLine("Starting the server...");
                server.Serve();
            }
            catch (Exception x)
            {
                Console.WriteLine(x.StackTrace);
            }
            Console.WriteLine("done.");
        }
Exemple #3
0
        static void Main(string[] args)
        {
            if (args.Length < 4)
            {
                Console.WriteLine("server [ns] [hc] [keyname] [key]");
                return;
            }

            var ns      = args[0];
            var hc      = args[1];
            var keyname = args[2];
            var key     = args[3];

            var tokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider(keyname, key);
            var listenAddress = new Uri(string.Format("sb://{0}/{1}", ns, hc));

            try
            {
                CalculatorHandler    handler   = new CalculatorHandler();
                Calculator.Processor processor = new Calculator.Processor(handler);

                TServerTransport serverTransport = new HybridConnectionListenerServerTransport(
                    new HybridConnectionListener(listenAddress, tokenProvider));

                TServer server = new TSimpleServer(processor, serverTransport);

                // Use this for a multithreaded server
                // server = new TThreadPoolServer(processor, serverTransport);

                Console.WriteLine("Starting the server...");
                server.Serve();
            }
            catch (Exception x)
            {
                Console.WriteLine(x.StackTrace);
            }
            Console.WriteLine("done.");
        }
Exemple #4
0
        public static void Main()
        {
            try
            {
                CalculatorHandler handler = new CalculatorHandler();
                Calculator.Processor processor = new Calculator.Processor(handler);
                TServerTransport serverTransport = new TServerSocket(9090);
                TServer server = new TSimpleServer(processor, serverTransport);

                // Use this for a multithreaded server
                // server = new TThreadPoolServer(processor, serverTransport);

                Console.WriteLine("Starting the server...");
                server.Serve();
            }
            catch (Exception x)
            {
                Console.WriteLine(x.StackTrace);
            }
            Console.WriteLine("done.");
        }
        public async Task Run(string listenAddress, string listenToken)
        {
            try
            {
                CalculatorHandler handler = new CalculatorHandler();
                Calculator.Processor processor = new Calculator.Processor(handler);

                TServerTransport serverTransport = new RelayListenerServerTransport(
                   new RelayListener(listenAddress,
                    TokenProvider.CreateSharedAccessSignatureTokenProvider(listenToken),
                    RelayAddressType.Configured));

                TServer server = new TSimpleServer(processor, serverTransport);

                // Use this for a multithreaded server
                // server = new TThreadPoolServer(processor, serverTransport);

                Console.WriteLine("Starting the server...");
                server.Serve();
            }
            catch (Exception x)
            {
                Console.WriteLine(x.StackTrace);
            }
            Console.WriteLine("done.");
        }