Changeset 5409 in ntrip


Ignore:
Timestamp:
Sep 10, 2013, 3:15:35 PM (8 years ago)
Author:
mervart
Message:
 
Location:
trunk/GnssCenter/map_stations
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GnssCenter/map_stations/thriftclient.cpp

    r5407 r5409  
    1414using namespace boost;
    1515
    16 // // Program
    17 // //////////////////////////////////////////////////////////////////////////////
    18 // int main(int argc, char **argv) {
    19 //
    20 //   // Parse Input Options
    21 //   // -------------------
    22 //   map<string, string> OPT;
    23 //   parseCmdLine(argc, argv, OPT);
    24 //   if (OPT.find("port") == OPT.end()) {
    25 //     cerr << "usage: rtnetThriftClient [--host <host>] --port <port>" << endl;
    26 //     return 1;
    27 //   }
    28 //   string host = OPT.find("host") == OPT.end() ? "localhost" : OPT["host"];
    29 //   int    port; istringstream(OPT["port"]) >> port;
    30 //
    31 //   shared_ptr<TSocket>     socket(new TSocket(host, port));
    32 //   shared_ptr<TTransport>  transport(new TBufferedTransport(socket));
    33 //   shared_ptr<TProtocol>   protocol(new TBinaryProtocol(transport));
    34 //   shared_ptr<RtnetDataIf> dataHandler(new t_thriftClient());
    35 //   shared_ptr<TProcessor>  processor(new RtnetDataProcessor(dataHandler));
    36 //
    37 //   try {
    38 //     transport->open();
    39 //
    40 //     while (processor->process(protocol,protocol,0)) {}
    41 //
    42 //     transport->close();
    43 //   }
    44 //   catch (TException& e) {
    45 //     cerr << "Caught an exception generated by Thrift: " << e.what() << endl;
    46 //     return 1;
    47 //   }
    48 //   catch (...) {
    49 //     cerr << "Unknown exception" << endl;
    50 //     return 1;
    51 //   }
    52 //
    53 //   return 0;
    54 // }
     16// Constructor
     17//////////////////////////////////////////////////////////////////////////////
     18t_thriftClient::t_thriftClient() {
     19
     20}
     21
     22// Destructor
     23//////////////////////////////////////////////////////////////////////////////
     24t_thriftClient::~t_thriftClient() {
     25
     26}
     27
     28// Run (virtual)
     29//////////////////////////////////////////////////////////////////////////////
     30void t_thriftClient::run() {
     31
     32  string host = "rtnet.rtcm-ntrip.org";
     33  int    port = 7777;
     34
     35  shared_ptr<TSocket>     socket(new TSocket(host, port));
     36  shared_ptr<TTransport>  transport(new TBufferedTransport(socket));
     37  shared_ptr<TProtocol>   protocol(new TBinaryProtocol(transport));
     38  shared_ptr<RtnetDataIf> dataHandler(new t_thriftClient());
     39  shared_ptr<TProcessor>  processor(new RtnetDataProcessor(dataHandler));
     40
     41  try {
     42    transport->open();
     43    while (processor->process(protocol,protocol,0)) {}
     44    transport->close();
     45  }
     46  catch (TException& e) {
     47    cerr << "Caught an exception generated by Thrift: " << e.what() << endl;
     48  }
     49  catch (...) {
     50    cerr << "Unknown exception" << endl;
     51  }
     52}
    5553
    5654// Handle Satellite Positions
  • trunk/GnssCenter/map_stations/thriftclient.h

    r5407 r5409  
    44#include <string>
    55#include <map>
     6#include <QThread>
    67
    78#include <transport/TSocket.h>
     
    1516// Handler Class Definition
    1617//////////////////////////////////////////////////////////////////////////////
    17 class t_thriftClient : public com::gpssolutions::rtnet::RtnetDataIf {
     18class t_thriftClient : public com::gpssolutions::rtnet::RtnetDataIf, QThread {
    1819 public:
    19   t_thriftClient() {}
    20   ~t_thriftClient() {}
     20  t_thriftClient();
     21  ~t_thriftClient();
     22  virtual void run();
    2123
    2224  void startDataStream() {}
Note: See TracChangeset for help on using the changeset viewer.