source: ntrip/trunk/BNC/src/bncnetqueryudp0.cpp@ 6833

Last change on this file since 6833 was 6787, checked in by stuerze, 10 years ago

add keep-alive request to send gga message in ntrip version 1 mode without interruption

File size: 2.0 KB
Line 
1/* -------------------------------------------------------------------------
2 * BKG NTRIP Client
3 * -------------------------------------------------------------------------
4 *
5 * Class: bncNetQueryUdp0
6 *
7 * Purpose: Blocking Network Requests (plain UDP, no NTRIP)
8 *
9 * Author: L. Mervart
10 *
11 * Created: 04-Feb-2009
12 *
13 * Changes:
14 *
15 * -----------------------------------------------------------------------*/
16
17#include "bncnetqueryudp0.h"
18
19// Constructor
20////////////////////////////////////////////////////////////////////////////
21bncNetQueryUdp0::bncNetQueryUdp0() {
22 _udpSocket = 0;
23 _eventLoop = new QEventLoop(this);
24}
25
26// Destructor
27////////////////////////////////////////////////////////////////////////////
28bncNetQueryUdp0::~bncNetQueryUdp0() {
29 delete _eventLoop;
30 delete _udpSocket;
31}
32
33//
34////////////////////////////////////////////////////////////////////////////
35void bncNetQueryUdp0::stop() {
36 _eventLoop->quit();
37 _status = finished;
38}
39
40//
41////////////////////////////////////////////////////////////////////////////
42void bncNetQueryUdp0::waitForRequestResult(const QUrl&, QByteArray&) {
43}
44
45//
46////////////////////////////////////////////////////////////////////////////
47void bncNetQueryUdp0::waitForReadyRead(QByteArray& outData) {
48
49 // Wait Loop
50 // ---------
51 if (!_udpSocket->hasPendingDatagrams()) {
52 _eventLoop->exec();
53 }
54
55 // Append Data
56 // -----------
57 QByteArray datagram;
58 datagram.resize(_udpSocket->pendingDatagramSize());
59 _udpSocket->readDatagram(datagram.data(), datagram.size());
60
61 outData.append(datagram);
62}
63
64// Connect to Caster, send the Request
65////////////////////////////////////////////////////////////////////////////
66void bncNetQueryUdp0::startRequest(const QUrl& url, const QByteArray& /* gga */) {
67
68 _status = running;
69
70 delete _udpSocket;
71 _udpSocket = new QUdpSocket();
72 _udpSocket->bind(url.port());
73
74 connect(_udpSocket, SIGNAL(readyRead()), _eventLoop, SLOT(quit()));
75}
76
77void bncNetQueryUdp0::keepAliveRequest(const QUrl& /* url */, const QByteArray& /* gga */) {
78}
Note: See TracBrowser for help on using the repository browser.