kopia lustrzana https://gitlab.com/eliggett/wfview
Improve server disconnection/cleanup
rodzic
35316dcd04
commit
869cde74b8
|
@ -242,7 +242,13 @@ void udpServer::controlReceived()
|
||||||
{
|
{
|
||||||
qInfo(logUdpServer()) << current->ipAddress.toString() << ": Received 'disconnect' request";
|
qInfo(logUdpServer()) << current->ipAddress.toString() << ": Received 'disconnect' request";
|
||||||
sendControl(current, 0x00, in->seq);
|
sendControl(current, 0x00, in->seq);
|
||||||
//current->wdTimer->stop(); // Keep watchdog running to delete stale connection.
|
|
||||||
|
if (current->audioClient != Q_NULLPTR) {
|
||||||
|
deleteConnection(&audioClients, current->audioClient);
|
||||||
|
}
|
||||||
|
if (current->civClient != Q_NULLPTR) {
|
||||||
|
deleteConnection(&civClients, current->civClient);
|
||||||
|
}
|
||||||
deleteConnection(&controlClients, current);
|
deleteConnection(&controlClients, current);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -443,22 +449,6 @@ void udpServer::civReceived()
|
||||||
|
|
||||||
QDateTime now = QDateTime::currentDateTime();
|
QDateTime now = QDateTime::currentDateTime();
|
||||||
|
|
||||||
bool userOK = false;
|
|
||||||
foreach(CLIENT * client, controlClients)
|
|
||||||
{
|
|
||||||
if (client != Q_NULLPTR)
|
|
||||||
{
|
|
||||||
if (client->ipAddress == datagram.senderAddress() && client->isAuthenticated)
|
|
||||||
{
|
|
||||||
userOK = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!userOK)
|
|
||||||
{
|
|
||||||
qDebug(logUdpServer()) << "user is NOT authenticated but attempted CI-V connection!";
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach(CLIENT * client, civClients)
|
foreach(CLIENT * client, civClients)
|
||||||
{
|
{
|
||||||
if (client != Q_NULLPTR)
|
if (client != Q_NULLPTR)
|
||||||
|
@ -467,13 +457,25 @@ void udpServer::civReceived()
|
||||||
{
|
{
|
||||||
current = client;
|
current = client;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current == Q_NULLPTR)
|
if (current == Q_NULLPTR)
|
||||||
{
|
{
|
||||||
current = new CLIENT();
|
current = new CLIENT();
|
||||||
|
|
||||||
|
foreach(CLIENT* client, controlClients)
|
||||||
|
{
|
||||||
|
if (client != Q_NULLPTR)
|
||||||
|
{
|
||||||
|
if (client->ipAddress == datagram.senderAddress() && client->isAuthenticated && client->civClient == Q_NULLPTR)
|
||||||
|
{
|
||||||
|
current->controlClient = client;
|
||||||
|
client->civClient = current;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
current->type = "CIV";
|
current->type = "CIV";
|
||||||
current->civId = 0;
|
current->civId = 0;
|
||||||
current->connected = true;
|
current->connected = true;
|
||||||
|
@ -508,6 +510,11 @@ void udpServer::civReceived()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (current->controlClient == Q_NULLPTR || !current->controlClient->isAuthenticated)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (r.length())
|
switch (r.length())
|
||||||
{
|
{
|
||||||
/* case (CONTROL_SIZE):
|
/* case (CONTROL_SIZE):
|
||||||
|
@ -596,22 +603,6 @@ void udpServer::audioReceived()
|
||||||
|
|
||||||
QDateTime now = QDateTime::currentDateTime();
|
QDateTime now = QDateTime::currentDateTime();
|
||||||
|
|
||||||
bool userOK = false;
|
|
||||||
foreach(CLIENT * client, controlClients)
|
|
||||||
{
|
|
||||||
if (client != Q_NULLPTR)
|
|
||||||
{
|
|
||||||
if (client->ipAddress == datagram.senderAddress() && client->isAuthenticated)
|
|
||||||
{
|
|
||||||
userOK = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!userOK)
|
|
||||||
{
|
|
||||||
qDebug(logUdpServer()) << "user is NOT authenticated but attempted CI-V connection!";
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach(CLIENT * client, audioClients)
|
foreach(CLIENT * client, audioClients)
|
||||||
{
|
{
|
||||||
if (client != Q_NULLPTR)
|
if (client != Q_NULLPTR)
|
||||||
|
@ -625,6 +616,17 @@ void udpServer::audioReceived()
|
||||||
if (current == Q_NULLPTR)
|
if (current == Q_NULLPTR)
|
||||||
{
|
{
|
||||||
current = new CLIENT();
|
current = new CLIENT();
|
||||||
|
foreach(CLIENT* client, controlClients)
|
||||||
|
{
|
||||||
|
if (client != Q_NULLPTR)
|
||||||
|
{
|
||||||
|
if (client->ipAddress == datagram.senderAddress() && client->isAuthenticated && client->audioClient == Q_NULLPTR)
|
||||||
|
{
|
||||||
|
current->controlClient = client;
|
||||||
|
client->audioClient = current;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
current->type = "Audio";
|
current->type = "Audio";
|
||||||
current->connected = true;
|
current->connected = true;
|
||||||
current->timeConnected = QDateTime::currentDateTime();
|
current->timeConnected = QDateTime::currentDateTime();
|
||||||
|
|
|
@ -117,6 +117,9 @@ private:
|
||||||
|
|
||||||
quint8 civId;
|
quint8 civId;
|
||||||
bool isAuthenticated;
|
bool isAuthenticated;
|
||||||
|
CLIENT* controlClient = Q_NULLPTR;
|
||||||
|
CLIENT* civClient=Q_NULLPTR;
|
||||||
|
CLIENT* audioClient=Q_NULLPTR;
|
||||||
};
|
};
|
||||||
|
|
||||||
void controlReceived();
|
void controlReceived();
|
||||||
|
|
Ładowanie…
Reference in New Issue