Changeset 1360 in ntrip


Ignore:
Timestamp:
Dec 27, 2008, 7:23:27 PM (15 years ago)
Author:
mervart
Message:

* empty log message *

Location:
trunk/BNC
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/bncsocket.cpp

    r1358 r1360  
    3333  _socket = 0;
    3434  _http   = 0;
     35  _buffer = 0;
    3536}
    3637
     
    4142  delete _socket;
    4243  delete _http;
     44  delete _buffer;
    4345}
    4446
     
    8587////////////////////////////////////////////////////////////////////////////
    8688qint64 bncSocket::bytesAvailable() const {
    87   if (_socket) {
     89  if      (_http) {
     90    for (int ii = 1; ii < 10; ii++) {
     91      cout << "bytesAvailable " << _http->bytesAvailable() << endl;
     92      msleep(100);
     93    }
     94    return _http->bytesAvailable();
     95  }
     96  else if (_socket) {
    8897    return _socket->bytesAvailable();
    8998  }
     
    96105////////////////////////////////////////////////////////////////////////////
    97106bool bncSocket::canReadLine() const {
    98   if (_socket) {
     107  if      (_buffer) {
     108    return _buffer->canReadLine();
     109  }
     110  else if (_socket) {
    99111    return _socket->canReadLine();
    100112  }
     
    107119////////////////////////////////////////////////////////////////////////////
    108120QByteArray bncSocket::readLine(qint64 maxlen) {
    109   if (_socket) {
     121  if      (_buffer) {
     122    return _buffer->readLine(maxlen);
     123  }
     124  else if (_socket) {
    110125    return _socket->readLine(maxlen);
    111126  }
     
    118133////////////////////////////////////////////////////////////////////////////
    119134bool bncSocket::waitForReadyRead(int msecs) {
    120   if (_socket) {
     135  if      (_http) {
     136    msleep(10);
     137  }
     138  else if (_socket) {
    121139    return _socket->waitForReadyRead(msecs);
    122140  }
     
    301319//
    302320////////////////////////////////////////////////////////////////////////////
    303 void bncSocket::slotReadyRead(const QHttpResponseHeader&) {
    304   cout << "slotReadyRead" << endl;
    305   QByteArray buffer = _http->readAll();
    306   cout << buffer.data();
     321void bncSocket::slotReadyRead() {
     322  cout << "slotReadyRead " << _buffer->size() << endl;
    307323}
    308324
     
    329345                         int timeOut, QString& msg) {
    330346
    331   delete _socket;
    332   _socket = new QTcpSocket();
    333 
    334347  delete _http;
    335348  _http = new QHttp();
    336349 
    337   _http->setSocket(_socket);
    338 
    339350  _http->setHost(url.host());
    340351
     
    359370  connect(_http, SIGNAL(requestFinished(int, bool)),
    360371          this, SLOT(slotRequestFinished(int, bool)));
    361   connect(_http, SIGNAL(readyRead(const QHttpResponseHeader&)),
    362           this, SLOT(slotReadyRead(const QHttpResponseHeader&)));
    363372  connect(_http, SIGNAL(sslErrors(const QList<QSslError>&)),
    364373          this, SLOT(slotSslErrors(const QList<QSslError>&)));
    365374
    366   _http->request(request);
     375  _buffer = new QBuffer();
     376  _buffer->open(QBuffer::ReadWrite);
     377  connect(_buffer, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
     378
     379  _http->request(request, 0, _buffer);
    367380
    368381  return success;
    369382}
     383
     384// void startQuery(...)
     385// {
     386//      m_eventLoop = new QEventLoop(this);
     387//      connect(this, SIGNAL(singleQueryDone()), m_eventLoop, SLOT(quit()));
     388//      connect( qHttp, SIGNAL( requestFinished(int,bool) ), this,
     389//              SLOT( dataDone(int, bool) ) );
     390//      qHttp->request( header, QByteArray(), m_buffer );
     391// }
     392//
     393// void dataDone( int, bool )
     394// {
     395//      emit singleQueryDone();
     396// }
     397//
     398// void blockingThing()
     399// {
     400//         startQuery( );
     401//         m_eventLoop->exec(QEventLoop::ExcludeUserInputEvents);
     402// }
     403//
  • trunk/BNC/bncsocket.h

    r1357 r1360  
    3535  void slotDone(bool);
    3636  void slotRequestFinished(int, bool);
    37   void slotReadyRead(const QHttpResponseHeader&);
     37  void slotReadyRead();
    3838  void slotSslErrors(const QList<QSslError>&);
    3939
     
    4545  QTcpSocket* _socket;
    4646  QHttp*      _http;     
     47  QBuffer*    _buffer;
    4748};
    4849
Note: See TracChangeset for help on using the changeset viewer.