Changeset 6787 in ntrip for trunk/BNC/src/bncnetqueryv1.cpp


Ignore:
Timestamp:
Apr 20, 2015, 4:13:12 PM (9 years ago)
Author:
stuerze
Message:

add keep-alive request to send gga message in ntrip version 1 mode without interruption

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/src/bncnetqueryv1.cpp

    r6571 r6787  
    105105}
    106106
     107
     108// Already connected to Caster, send another Request
     109////////////////////////////////////////////////////////////////////////////
     110void bncNetQueryV1::keepAliveRequest(const QUrl& url, const QByteArray& gga) {
     111
     112  _status = running;
     113
     114  // Default scheme and path
     115  // -----------------------
     116  _url = url;
     117  if (_url.scheme().isEmpty()) {
     118    _url.setScheme("http");
     119  }
     120  if (_url.path().isEmpty()) {
     121    _url.setPath("/");
     122  }
     123
     124  // Connect the Socket
     125  // ------------------
     126  bncSettings settings;
     127  QString proxyHost = settings.value("proxyHost").toString();
     128  int     proxyPort = settings.value("proxyPort").toInt();
     129
     130  if ( proxyHost.isEmpty() ) {
     131    _socket->connectToHost(_url.host(), _url.port());
     132  }
     133  else {
     134    _socket->connectToHost(proxyHost, proxyPort);
     135  }
     136  if (!_socket->waitForConnected(_timeOut)) {
     137    delete _socket;
     138    _socket = 0;
     139    _status = error;
     140    return;
     141  }
     142
     143  // Send Request
     144  // ------------
     145   QByteArray reqStr;
     146
     147   // NMEA string to handle VRS stream
     148   // --------------------------------
     149   if (!gga.isEmpty()) {
     150     reqStr += gga + "\r\n";
     151   }
     152
     153   _socket->write(reqStr, reqStr.length());
     154
     155   if (!_socket->waitForBytesWritten(_timeOut)) {
     156     delete _socket;
     157     _socket = 0;
     158     _status = error;
     159     emit newMessage(_url.path().toAscii().replace(0,1,"")
     160                     + ": Write timeout", true);
     161     return;
     162   }
     163
     164}
     165
    107166// Connect to Caster, send the Request
    108167////////////////////////////////////////////////////////////////////////////
Note: See TracChangeset for help on using the changeset viewer.