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

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