Changeset 7180 in ntrip for trunk/BNC/src/bncgetthread.cpp
- Timestamp:
- Aug 14, 2015, 10:57:56 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/src/bncgetthread.cpp
r7153 r7180 128 128 _decoder = 0; 129 129 130 // NMEA Port 131 // ----------- 132 QListIterator<QString> iSta(settings.value("PPP/staTable").toStringList()); 133 int nmeaPort = 0; 134 while (iSta.hasNext()) { 135 QStringList hlp = iSta.next().split(","); 136 if (hlp.size() < 10) {continue;} 137 QByteArray mp = hlp[0].toAscii(); 138 if (_staID == mp) { 139 nmeaPort = hlp[9].toInt(); 140 } 141 } 142 if (nmeaPort != 0) { 143 _nmeaServer = new QTcpServer; 144 if ( !_nmeaServer->listen(QHostAddress::Any, nmeaPort) ) { 145 emit newMessage("bncCaster: Cannot listen on port", true); 146 } 147 else { 148 connect(_nmeaServer, SIGNAL(newConnection()), this, SLOT(slotNewNMEAConnection())); 149 connect(BNC_CORE, SIGNAL(newNMEAstr(QByteArray, QByteArray)), 150 this, SLOT(slotNewNMEAstr(QByteArray, QByteArray))); 151 _nmeaSockets = new QList<QTcpSocket*>; 152 _nmeaPortsMap[_staID] = nmeaPort; 153 } 154 } else { 155 _nmeaServer = 0; 156 _nmeaSockets = 0; 157 } 158 130 159 // Serial Port 131 160 // ----------- … … 371 400 delete this; 372 401 } 402 _nmeaPortsMap.remove(_staID); 403 delete _nmeaServer; 404 delete _nmeaSockets; 373 405 } 374 406 … … 879 911 } 880 912 } 913 914 void bncGetThread::slotNewNMEAConnection() { 915 _nmeaSockets->push_back(_nmeaServer->nextPendingConnection()); 916 emit( newMessage(QString("New PPP client on port: # %1") 917 .arg(_nmeaSockets->size()).toAscii(), true) ); 918 } 919 920 // 921 //////////////////////////////////////////////////////////////////////////// 922 void bncGetThread::slotNewNMEAstr(QByteArray staID, QByteArray str) { 923 if (_nmeaPortsMap.contains(staID)) { 924 int nmeaPort = _nmeaPortsMap.value(staID); 925 QMutableListIterator<QTcpSocket*> is(*_nmeaSockets); 926 while (is.hasNext()) { 927 QTcpSocket* sock = is.next(); 928 if (sock->localPort() == nmeaPort) { 929 if (sock->state() == QAbstractSocket::ConnectedState) { 930 sock->write(str); 931 } 932 else if (sock->state() != QAbstractSocket::ConnectingState) { 933 delete sock; 934 is.remove(); 935 } 936 } 937 } 938 } 939 }
Note:
See TracChangeset
for help on using the changeset viewer.