Showing the changes to gvr-interface/src/GVRInterface.cpp (1 of 4 files). Show all
Unified · Split
| @@ -17,4 +17,30 @@ GVRInterface::GVRInterface(int argc, char* argv[]) : · 16 unmodified lines | ||
| 17 | 17 | QGuiApplication(argc, argv) |
| 18 | 18 | { |
| 19 | 19 | NodeList* nodeList = NodeList::createInstance(NodeType::Agent); |
| 20 | + | |
| 21 | + connect(&nodeList->getNodeSocket(), &QUdpSocket::readyRead, this, &GVRInterface::processDatagrams); | |
| 22 | + | |
| 23 | + QTimer* domainServerTimer = new QTimer(this); | |
| 24 | + connect(domainServerTimer, &QTimer::timeout, nodeList, &NodeList::sendDomainServerCheckIn); | |
| 25 | + domainServerTimer->start(DOMAIN_SERVER_CHECK_IN_MSECS); | |
| 26 | + | |
| 27 | + QTimer* silentNodeRemovalTimer = new QTimer(this); | |
| 28 | + connect(silentNodeRemovalTimer, &QTimer::timeout, nodeList, &NodeList::removeSilentNodes); | |
| 29 | + silentNodeRemovalTimer->start(NODE_SILENCE_THRESHOLD_MSECS); | |
| 30 | +} | |
| 31 | + | |
| 32 | +void GVRInterface::processDatagrams() { | |
| 33 | + NodeList* nodeList = NodeList::getInstance(); | |
| 34 | + | |
| 35 | + HifiSockAddr senderSockAddr; | |
| 36 | + QByteArray incomingPacket; | |
| 37 | + | |
| 38 | + while (nodeList->getNodeSocket().hasPendingDatagrams()) { | |
| 39 | + incomingPacket.resize(nodeList->getNodeSocket().pendingDatagramSize()); | |
| 40 | + nodeList->getNodeSocket().readDatagram(incomingPacket.data(), incomingPacket.size(), | |
| 41 | + senderSockAddr.getAddressPointer(), senderSockAddr.getPortPointer()); | |
| 42 | + | |
| 43 | + qDebug() << "Processing a packet!"; | |
| 44 | + nodeList->processNodeData(senderSockAddr, incomingPacket); | |
| 45 | + } | |
| 20 | 46 | } |