source: ntrip/trunk/GnssCenter/thrift/test2/server.cpp@ 4943

Last change on this file since 4943 was 4943, checked in by mervart, 9 years ago
File size: 1.5 KB
Line 
1#include <iostream>
2#include <string>
3
4#include <thrift/protocol/TBinaryProtocol.h>
5#include <thrift/server/TThreadedServer.h>
6#include <thrift/transport/TServerSocket.h>
7#include <thrift/transport/TBufferTransports.h>
8
9#include "gen-cpp/myService.h"
10
11using namespace std;
12using namespace boost;
13using namespace ::apache::thrift;
14using namespace ::apache::thrift::protocol;
15using namespace ::apache::thrift::transport;
16using namespace ::apache::thrift::server;
17
18class myServiceHandler : virtual public myServiceIf {
19 public:
20 myServiceHandler() {}
21 void answer(std::string& answ, const std::string& question) {
22 // implemented on the client-side only
23 }
24};
25
26class myProcessorFactory : virtual public TProcessorFactory {
27 public:
28 myProcessorFactory() {};
29 shared_ptr<TProcessor> getProcessor(const TConnectionInfo& info) {
30 shared_ptr<myServiceHandler> handler(new myServiceHandler());
31 shared_ptr<TProcessor> processor(new myServiceProcessor(handler));
32 return processor;
33 }
34};
35
36int main(int argc, char **argv) {
37 int port = 9090;
38 shared_ptr<TServerSocket> serverTransport(new TServerSocket(port));
39 shared_ptr<myProcessorFactory> processorFactory(new myProcessorFactory());
40 shared_ptr<TTransportFactory> transportFactory(new TBufferedTransportFactory());
41 shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
42
43 TThreadedServer server(processorFactory, serverTransport,
44 transportFactory, protocolFactory);
45
46 server.serve();
47
48 return 0;
49}
50
Note: See TracBrowser for help on using the repository browser.