Changeset 1375 in ntrip for trunk/BNC/bnctabledlg.cpp


Ignore:
Timestamp:
Dec 28, 2008, 10:04:16 PM (15 years ago)
Author:
mervart
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/bnctabledlg.cpp

    r1373 r1375  
    4444#include "bncgetthread.h"
    4545#include "bncnetquery.h"
    46 #include "bncsocket.h"
    4746
    4847using namespace std;
     
    169168  url.setHost(casterHost);
    170169  url.setPort(casterPort);
    171 
    172   // Send the Request
    173   // ----------------
    174   const int timeOut = 10*1000;
    175   QString msg;
    176   bncSocket* socket = new bncSocket();
    177 
    178   //// beg test
    179   bncNetQuery* query = new bncNetQuery();
     170  url.setScheme("http");
     171  url.setPath("/");
     172
     173  bncNetQuery query;
    180174  QByteArray outData;
    181   cout << "before request" << endl;
    182   t_irc irc = query->waitForRequestResult(url, outData);
    183   cout << "after request " << irc << endl;
    184   cout << outData.data();
    185   return failure;
    186   //// end test
    187 
    188   if (socket->request(url, "", "", "", ntripVersion, timeOut, msg) != success) {
    189     delete socket;
     175  query.waitForRequestResult(url, outData);
     176  if (query.status() == bncNetQuery::finished) {
     177    QTextStream in(outData);
     178    QString line = in.readLine();
     179    while ( !line.isNull() ) {
     180      allLines.append(line);
     181      line = in.readLine();
     182    }
     183    allTables.insert(casterHost, allLines);
     184    return success;
     185  }
     186  else {
    190187    return failure;
    191188  }
    192 
    193   // Read Caster Response
    194   // --------------------
    195   bool proxyRespond = false;
    196   bool first = true;
    197   while (true) {
    198     if (socket->canReadLine()) {
    199       QString line = socket->readLine();
    200 
    201       // Skip messages from proxy server
    202       // -------------------------------
    203       if (line.indexOf("SOURCETABLE 200 OK") == -1 &&
    204           line.indexOf("200 OK")             != -1 ) {
    205         proxyRespond = true;
    206       }
    207       if (proxyRespond) {
    208         if (line.trimmed().isEmpty()) {
    209           proxyRespond = false;
    210         }
    211         continue;
    212       }
    213 
    214       allLines.push_back(line);
    215       if (first) {
    216         first = false;
    217         if (line.indexOf("SOURCETABLE 200 OK") != 0) {
    218           if (ntripVersion == "1") {
    219             break;
    220           }
    221         }
    222       }
    223       else {
    224         if (line.indexOf("ENDSOURCETABLE") == 0) {
    225           break;
    226         }
    227       }
    228     }
    229     else {
    230       socket->waitForReadyRead(timeOut);
    231       if (socket->bytesAvailable() > 0) {
    232         continue;
    233       }
    234       else {
    235         break;
    236       }
    237     }
    238   }
    239   ///  delete socket;
    240 
    241   allTables.insert(casterHost, allLines);
    242   return success;
    243189}
    244190
Note: See TracChangeset for help on using the changeset viewer.