Пример #1
0
        static void Execute(int port)
        {
            try
            {
                // create protocol factory, default to BinaryProtocol
                TProtocolFactory  ProtocolFactory  = new TBinaryProtocol.Factory(true, true);
                TServerTransport  servertrans      = new TServerSocket(port, 0, false);
                TTransportFactory TransportFactory = new TFramedTransport.Factory();

                BenchmarkService.Iface benchHandler   = new BenchmarkServiceImpl();
                TProcessor             benchProcessor = new BenchmarkService.Processor(benchHandler);

                Aggr.Iface aggrHandler   = new AggrServiceImpl();
                TProcessor aggrProcessor = new Aggr.Processor(aggrHandler);

                TMultiplexedProcessor multiplex = new TMultiplexedProcessor();
                multiplex.RegisterProcessor(Constants.NAME_BENCHMARKSERVICE, benchProcessor);
                multiplex.RegisterProcessor(Constants.NAME_AGGR, aggrProcessor);

                TServer ServerEngine = new TSimpleServer(multiplex, servertrans, TransportFactory, ProtocolFactory);

                Console.WriteLine("Starting the server ...");
                ServerEngine.Serve();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
        static void Execute(int port)
        {
            try
            {
                // create protocol factory, default to BinaryProtocol
                TProtocolFactory ProtocolFactory = new TBinaryProtocol.Factory(true,true);
                TServerTransport servertrans = new TServerSocket(port, 0, false);
                TTransportFactory TransportFactory = new TFramedTransport.Factory();

                BenchmarkService.Iface benchHandler = new BenchmarkServiceImpl();
                TProcessor benchProcessor = new BenchmarkService.Processor(benchHandler);

                Aggr.Iface aggrHandler = new AggrServiceImpl();
                TProcessor aggrProcessor = new Aggr.Processor(aggrHandler);

                TMultiplexedProcessor multiplex = new TMultiplexedProcessor();
                multiplex.RegisterProcessor(Constants.NAME_BENCHMARKSERVICE, benchProcessor);
                multiplex.RegisterProcessor(Constants.NAME_AGGR, aggrProcessor);

                TServer ServerEngine = new TSimpleServer(multiplex, servertrans, TransportFactory, ProtocolFactory);

                Console.WriteLine("Starting the server ...");
                ServerEngine.Serve();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }