Changeset 1719 in ntrip


Ignore:
Timestamp:
Mar 4, 2009, 9:11:06 PM (15 years ago)
Author:
mervart
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/bncnetqueryudp.cpp

    r1718 r1719  
    2828////////////////////////////////////////////////////////////////////////////
    2929bncNetQueryUdp::bncNetQueryUdp() {
     30  _port      = 0;
    3031  _udpSocket = 0;
    3132  _eventLoop = new QEventLoop(this);
     
    8384  _status = running;
    8485
     86  // Default scheme and path
     87  // -----------------------
     88  _url = url;
     89  if (_url.scheme().isEmpty()) {
     90    _url.setScheme("http");
     91  }
     92  if (_url.path().isEmpty()) {
     93    _url.setPath("/");
     94  }
     95
     96  _port = _url.port();
     97
    8598  delete _udpSocket;
    8699  _udpSocket = new QUdpSocket();
    87   _udpSocket->bind(0);
    88100  connect(_udpSocket, SIGNAL(readyRead()), _eventLoop, SLOT(quit()));
    89   QByteArray clientPort = QString("%1").arg(_udpSocket->localPort()).toAscii();
    90 
    91   // Send initial RTP packet for firewall handling
    92   // ---------------------------------------------
    93   char rtpbuffer[12];
    94   rtpbuffer[0]  = (2<<6);
    95   rtpbuffer[1]  = 96;
    96   rtpbuffer[2]  = 0;
    97   rtpbuffer[3]  = 0;
    98   rtpbuffer[4]  = 0;
    99   rtpbuffer[5]  = 0;
    100   rtpbuffer[6]  = 0;
    101   rtpbuffer[7]  = 0;
    102   rtpbuffer[8]  = 0;
    103   rtpbuffer[9]  = 0;
    104   rtpbuffer[10] = 0;
    105   rtpbuffer[11] = 0;
    106101
    107102  QHostInfo hInfo = QHostInfo::fromName(url.host());
    108103
    109   QHostAddress address;
    110104  if (!hInfo.addresses().isEmpty()) {
    111     address = hInfo.addresses().first();
    112     _udpSocket->writeDatagram(rtpbuffer, 12, address, url.port());
     105
     106    _address = hInfo.addresses().first();
     107
     108    // Send initial RTP packet for firewall handling
     109    // ---------------------------------------------
     110    char rtpbuffer[12];
     111    rtpbuffer[0]  = (2<<6);
     112    rtpbuffer[1]  = 96;
     113    rtpbuffer[2]  = 0;
     114    rtpbuffer[3]  = 0;
     115    rtpbuffer[4]  = 0;
     116    rtpbuffer[5]  = 0;
     117    rtpbuffer[6]  = 0;
     118    rtpbuffer[7]  = 0;
     119    rtpbuffer[8]  = 0;
     120    rtpbuffer[9]  = 0;
     121    rtpbuffer[10] = 0;
     122    rtpbuffer[11] = 0;
     123
     124    _udpSocket->writeDatagram(rtpbuffer, 12, _address, _port);
     125
     126    // Send Request
     127    // ------------
     128    QString uName = QUrl::fromPercentEncoding(_url.userName().toAscii());
     129    QString passW = QUrl::fromPercentEncoding(_url.password().toAscii());
     130    QByteArray userAndPwd;
     131   
     132    if(!uName.isEmpty() || !passW.isEmpty()) {
     133      userAndPwd = "Authorization: Basic " + (uName.toAscii() + ":" +
     134      passW.toAscii()).toBase64() + "\r\n";
     135    }
     136   
     137    QByteArray reqStr = "GET " + _url.path().toAscii() + " HTTP/1.0\r\n"
     138                      + "User-Agent: NTRIP BNC/" BNCVERSION "\r\n"
     139                      + userAndPwd + "\r\n";
     140   
     141    // NMEA string to handle VRS stream
     142    // --------------------------------
     143    if (!gga.isEmpty()) {
     144      reqStr += gga + "\r\n";
     145    }
     146
    113147  }
    114 
    115148}
    116149
Note: See TracChangeset for help on using the changeset viewer.