source: ntrip/trunk/GnssCenter/thrift/rtnet_sdo_example/RtnetDataListener.cpp@ 5017

Last change on this file since 5017 was 4941, checked in by mervart, 11 years ago
File size: 1.7 KB
Line 
1#include "RtnetDataListener.h"
2
3#include <cstdio>
4
5using namespace apache::thrift;
6using namespace apache::thrift::protocol;
7using namespace com::gpssolutions::rtnet;
8
9RtnetDataListener::RtnetDataListener(boost::shared_ptr<TProtocol>& protocol,
10 boost::shared_ptr<ConnectionStatusMonitor>& connectionMonitor,
11 boost::shared_ptr<com::gpssolutions::rtnet::RtnetDataIf> dataHandler)
12 : ConnectionRequiredRunnable(connectionMonitor,"StreamDataRequestService"),
13 dataHandler_(dataHandler),
14 protocol_(protocol),
15 processor_()
16{
17 processor_ = boost::shared_ptr<RtnetDataProcessor>(new RtnetDataProcessor(dataHandler_));
18}
19
20RtnetDataListener::~RtnetDataListener() {
21}
22
23void
24RtnetDataListener::run() {
25 printf("Starting RtnetDataListener thread.\n");
26 while (!stop_) {
27 printf("RtnetDataListener::waiting for connection\n");
28 connectWait();
29 printf("RtnetDataListener::Connected to rtnet\n");
30 if (stop_) {
31 printf("Quitting RtnetDataListener thread (stop is true)\n");
32 return;
33 }
34 try {
35 while (processor_->process(protocol_,protocol_,0)) {}
36 } catch(TException& e) {
37 fprintf(stderr,"Caught an exception generated by Thrift in RtnetDataListener: %s\n",e.what());
38 } catch(...) {
39 fprintf(stderr,"Unknown exception generated by Thrift in RtnetDataListener\n");
40 }
41 if (!stop_)
42 disconnected();
43 }
44 printf("Quitting RtnetDataListener thread\n");
45}
46
47void
48RtnetDataListener::stop(){
49 printf("RtnetDataListener::stop()\n");
50 protocol_->getTransport()->close();
51 ConnectionRequiredRunnable::stop();
52}
53
Note: See TracBrowser for help on using the repository browser.