mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
карта блок-в. Блокировка правильная. Множ. доступ
This commit is contained in:
@@ -35,15 +35,17 @@ bool MultiThreadServer::startServer()
|
||||
//connect(tcpServer, &QTcpServer::newConnection, this, &ServerLMSWidget::slotNewConnection,Qt::AutoConnection);
|
||||
|
||||
if(!listen(QHostAddress::Any, hostPort))
|
||||
{
|
||||
Logger::instance().log("SERVER: start ERROR");
|
||||
{
|
||||
stateServer = stoped;
|
||||
Logger::instance().log("SERVER: start ERROR");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger::instance().log("SERVER: start OK");
|
||||
|
||||
stateServer = started;
|
||||
slot_BlockAutorization(false, "SERVER", "StartServer");
|
||||
Logger::instance().log("SERVER: start OK");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -59,7 +61,8 @@ bool MultiThreadServer::stopServer()
|
||||
|
||||
//Закрываем сервер
|
||||
close();
|
||||
stateServer = stoped;
|
||||
stateServer = stoped;
|
||||
slot_BlockAutorization(true, "SERVER", "StopServer");
|
||||
Logger::instance().log("SERVER: stop OK");
|
||||
return true;
|
||||
}
|
||||
@@ -94,8 +97,13 @@ void MultiThreadServer::disableClients()
|
||||
|
||||
handler->sigSendXmlAnswer(arrayAnswer, PacketType::TYPE_XMLANSWER);
|
||||
QString str = QString(arrayAnswer);
|
||||
|
||||
QString fullName = handler->getClient()->getFullName();
|
||||
|
||||
processingSystem->processingClientDeAutorization(handler->getClient()->getLogin());
|
||||
|
||||
slot_BlockAutorization(false, fullName, "DisableClient");
|
||||
|
||||
handler->sigSocketClose();
|
||||
//clientsMap.remove(idSocket);
|
||||
removeClient(idSocket);
|
||||
@@ -119,8 +127,12 @@ void MultiThreadServer::slotDisconnectClient(QString peerAddress, QString peerPo
|
||||
|
||||
ClientDeAutorization clientDeAutorization;
|
||||
clientDeAutorization.Login = login;
|
||||
|
||||
//QString fullName = client->getClient()->getFullName();
|
||||
|
||||
processingSystem->processingClientDeAutorization(client, clientDeAutorization);
|
||||
|
||||
//slot_BlockAutorization(false, fullName, "DisconnectClient");
|
||||
removeClient(idSocket);
|
||||
delete client;
|
||||
continue;
|
||||
@@ -135,6 +147,37 @@ void MultiThreadServer::slotDisconnectClient(QString peerAddress, QString peerPo
|
||||
serverLmsWidget->getProcessingSystem()->processingClientDeAutorization(login);
|
||||
}
|
||||
|
||||
bool MultiThreadServer::slot_BlockAutorization(bool block, QString whoFullName, QString type)
|
||||
{
|
||||
bool res = true;
|
||||
bool blockRes = false;
|
||||
|
||||
if(block)
|
||||
{
|
||||
this->blockAutorization();
|
||||
blockersMap.insert(whoFullName, type);
|
||||
blockRes = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
blockersMap.take(whoFullName);
|
||||
if(!blockersMap.count())
|
||||
this->unBlockAutorization();
|
||||
}
|
||||
|
||||
if(res)
|
||||
{
|
||||
if(blockRes)
|
||||
emit signal_sendPacketToAllClients(PacketType::BUSY);
|
||||
else
|
||||
emit signal_sendPacketToAllClients(PacketType::FREE);
|
||||
|
||||
emit signal_BlockAutorizationIndicate(block, whoFullName, type);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void MultiThreadServer::removeClient(int idSocket)
|
||||
{
|
||||
clientsMap->remove(idSocket);
|
||||
|
||||
Reference in New Issue
Block a user