Line | |
---|
1 | #include <iostream>
|
---|
2 |
|
---|
3 | #include <thrift/protocol/TBinaryProtocol.h>
|
---|
4 | #include <thrift/server/TSimpleServer.h>
|
---|
5 | #include <thrift/transport/TServerSocket.h>
|
---|
6 | #include <thrift/transport/TBufferTransports.h>
|
---|
7 |
|
---|
8 | #include "gen-cpp/myService.h"
|
---|
9 |
|
---|
10 | using namespace std;
|
---|
11 | using namespace boost;
|
---|
12 | using namespace ::apache::thrift;
|
---|
13 | using namespace ::apache::thrift::protocol;
|
---|
14 | using namespace ::apache::thrift::transport;
|
---|
15 | using namespace ::apache::thrift::server;
|
---|
16 |
|
---|
17 | class myServiceHandler : virtual public myServiceIf {
|
---|
18 | public:
|
---|
19 | myServiceHandler() {}
|
---|
20 | void answer(std::string& answ, const std::string& question) {
|
---|
21 | cout << "Client asks: " << question << endl;
|
---|
22 | answ = "I am well, thanks.";
|
---|
23 | }
|
---|
24 | };
|
---|
25 |
|
---|
26 | int main(int argc, char **argv) {
|
---|
27 | int port = 9090;
|
---|
28 | shared_ptr<myServiceHandler> handler(new myServiceHandler());
|
---|
29 | shared_ptr<TProcessor> processor(new myServiceProcessor(handler));
|
---|
30 | shared_ptr<TServerSocket> serverTransport(new TServerSocket(port));
|
---|
31 | shared_ptr<TTransportFactory> transportFactory(new TBufferedTransportFactory());
|
---|
32 | shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
|
---|
33 |
|
---|
34 | TSimpleServer server(processor, serverTransport,
|
---|
35 | transportFactory, protocolFactory);
|
---|
36 | server.serve();
|
---|
37 | return 0;
|
---|
38 | }
|
---|
39 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.