forked from MagicalTux/dlockd
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDLockManager.cpp
More file actions
36 lines (28 loc) · 750 Bytes
/
DLockManager.cpp
File metadata and controls
36 lines (28 loc) · 750 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <QMetaObject>
#include <QCoreApplication>
#include <QHostAddress>
#include "DLockManager.hpp"
DLockManager::DLockManager(quint16 _port) {
port = _port;
}
void DLockManager::initSocket() {
udpSocket.bind(port);
qDebug("Server listening!");
connect(&udpSocket, SIGNAL(readyRead()),
this, SLOT(readPendingDatagrams()));
}
void DLockManager::readPendingDatagrams() {
while (udpSocket.hasPendingDatagrams()) {
QByteArray datagram;
datagram.resize(udpSocket.pendingDatagramSize());
QHostAddress sender;
quint16 senderPort;
udpSocket.readDatagram(datagram.data(), datagram.size(),
&sender, &senderPort);
//parse(datagram);
}
}
void DLockManager::terminate() {
qDebug("Exiting cleanly");
QCoreApplication::quit();
}