Changeset 1360 in ntrip
- Timestamp:
- Dec 27, 2008, 7:23:27 PM (16 years ago)
- Location:
- trunk/BNC
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/bncsocket.cpp
r1358 r1360 33 33 _socket = 0; 34 34 _http = 0; 35 _buffer = 0; 35 36 } 36 37 … … 41 42 delete _socket; 42 43 delete _http; 44 delete _buffer; 43 45 } 44 46 … … 85 87 //////////////////////////////////////////////////////////////////////////// 86 88 qint64 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) { 88 97 return _socket->bytesAvailable(); 89 98 } … … 96 105 //////////////////////////////////////////////////////////////////////////// 97 106 bool bncSocket::canReadLine() const { 98 if (_socket) { 107 if (_buffer) { 108 return _buffer->canReadLine(); 109 } 110 else if (_socket) { 99 111 return _socket->canReadLine(); 100 112 } … … 107 119 //////////////////////////////////////////////////////////////////////////// 108 120 QByteArray bncSocket::readLine(qint64 maxlen) { 109 if (_socket) { 121 if (_buffer) { 122 return _buffer->readLine(maxlen); 123 } 124 else if (_socket) { 110 125 return _socket->readLine(maxlen); 111 126 } … … 118 133 //////////////////////////////////////////////////////////////////////////// 119 134 bool bncSocket::waitForReadyRead(int msecs) { 120 if (_socket) { 135 if (_http) { 136 msleep(10); 137 } 138 else if (_socket) { 121 139 return _socket->waitForReadyRead(msecs); 122 140 } … … 301 319 // 302 320 //////////////////////////////////////////////////////////////////////////// 303 void bncSocket::slotReadyRead(const QHttpResponseHeader&) { 304 cout << "slotReadyRead" << endl; 305 QByteArray buffer = _http->readAll(); 306 cout << buffer.data(); 321 void bncSocket::slotReadyRead() { 322 cout << "slotReadyRead " << _buffer->size() << endl; 307 323 } 308 324 … … 329 345 int timeOut, QString& msg) { 330 346 331 delete _socket;332 _socket = new QTcpSocket();333 334 347 delete _http; 335 348 _http = new QHttp(); 336 349 337 _http->setSocket(_socket);338 339 350 _http->setHost(url.host()); 340 351 … … 359 370 connect(_http, SIGNAL(requestFinished(int, bool)), 360 371 this, SLOT(slotRequestFinished(int, bool))); 361 connect(_http, SIGNAL(readyRead(const QHttpResponseHeader&)),362 this, SLOT(slotReadyRead(const QHttpResponseHeader&)));363 372 connect(_http, SIGNAL(sslErrors(const QList<QSslError>&)), 364 373 this, SLOT(slotSslErrors(const QList<QSslError>&))); 365 374 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); 367 380 368 381 return success; 369 382 } 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 35 35 void slotDone(bool); 36 36 void slotRequestFinished(int, bool); 37 void slotReadyRead( const QHttpResponseHeader&);37 void slotReadyRead(); 38 38 void slotSslErrors(const QList<QSslError>&); 39 39 … … 45 45 QTcpSocket* _socket; 46 46 QHttp* _http; 47 QBuffer* _buffer; 47 48 }; 48 49
Note:
See TracChangeset
for help on using the changeset viewer.