mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2b656c2959 | |||
| a0e54c0e18 | |||
| a1f3e04fad | |||
| 517515e94e | |||
| 594aa8311e | |||
|
|
a3d6c2899b | ||
|
|
c16e99cc3e | ||
|
|
f2e36d35e4 |
@@ -15,6 +15,7 @@ kanban-plugin: board
|
|||||||
- [ ] QT клиент: сделать отключение кнопки обновить при появлении inline Инициализация
|
- [ ] QT клиент: сделать отключение кнопки обновить при появлении inline Инициализация
|
||||||
- [ ] 16.27 от 22.12
|
- [ ] 16.27 от 22.12
|
||||||
- [ ] Unity: ошибка при проигрывании - нажать на среднюю кнопку мыши
|
- [ ] Unity: ошибка при проигрывании - нажать на среднюю кнопку мыши
|
||||||
|
- [ ] не работает выключение QT клиента призагрузке
|
||||||
|
|
||||||
|
|
||||||
## feature client Unity
|
## feature client Unity
|
||||||
|
|||||||
@@ -41,5 +41,29 @@
|
|||||||
7. Unity: отправка в базовую версию
|
7. Unity: отправка в базовую версию
|
||||||
|
|
||||||
Сервер:
|
Сервер:
|
||||||
1. Выключение сервера -> рассылка все клиентам DISABLE. Клиенты должны отключится от сети
|
1. Загрузка контента с нуля и логин 2х машин под QT
|
||||||
2.
|
2. Загрузка контента с нуля и разлогин 2х машин под QT
|
||||||
|
3. Загрузка контента с нуля попытка обновления с QT клиента (под инструктором)
|
||||||
|
4. Загрузка контента с нуля попытка восстановления с QT клиента (под инструктором)
|
||||||
|
5. Загрузка контента с нуля и отправка сообщений между машинами Unity -> Unity
|
||||||
|
6. Загрузка контента с нуля выполнение задачи с Unity
|
||||||
|
7. Загрузка контента с нуля отправка FIM с Unity
|
||||||
|
8. Загрузка контента с нуля и отправка сообщений между машинами GUI -> Unity
|
||||||
|
9. Загрузка контента с нуля и изменение CFI
|
||||||
|
10. Загрузка контента с нуля логин 2х машин под Unity
|
||||||
|
11. Загрузка контента c нуля редактирование пользователей (Инструктор, обучаемый, группы)
|
||||||
|
12. Загрузка контента с нуля назначение FIM ГУИ
|
||||||
|
13. Загрузка контента с нуля назначение AMM ГУИ
|
||||||
|
14. Загрузка контента с нуля назначение FIM удаление и проверка ГУИ
|
||||||
|
15. Загрузка контента с нуля назначение AMM удаление ГУИ
|
||||||
|
16. Загрузка контента с нуля Авторизация 2х ГУИ
|
||||||
|
17. Загрузка контента с нуля Деавторизация 2х ГУИ
|
||||||
|
18. Загрузка контента с нуля переключение версии контента ГУИ
|
||||||
|
19. Загрузка контента с нуля удаление версии контента ГУИ
|
||||||
|
20. Загрузка контента с нуля копирование версии контента ГУИ
|
||||||
|
21. Загрузка контента с нуля запрос DOCS ГУИ
|
||||||
|
|
||||||
|
22. Назначение задач с 2х ГУИ параллельно (10 задач) (1 пользователю)
|
||||||
|
23. При просмотре задачи инструктором, меняется ее статус
|
||||||
|
24. Блокировка сервера в момент авторизации между QT и Unity
|
||||||
|
25. Попытка выгрузки изменений (Unity залогинен под одной версией) QT сервер изменил версию и далее через восстановление
|
||||||
@@ -22,7 +22,6 @@ enum PacketType
|
|||||||
TYPE_FILESIZE = 20,
|
TYPE_FILESIZE = 20,
|
||||||
TYPE_BIGXML = 21,
|
TYPE_BIGXML = 21,
|
||||||
UPDATE_DOCS_COMPLETE = 22,
|
UPDATE_DOCS_COMPLETE = 22,
|
||||||
TYPE_CFIUPDATE = 23,
|
|
||||||
TYPE_UPDATEDCFI = 24,
|
TYPE_UPDATEDCFI = 24,
|
||||||
|
|
||||||
TYPE_XMLANSWER_MESSAGE_FOR_GUI = 90,
|
TYPE_XMLANSWER_MESSAGE_FOR_GUI = 90,
|
||||||
@@ -108,7 +107,7 @@ inline QString enumToString(PacketType value) {
|
|||||||
case PacketType::RECALCULATE_DOCS: return "RECALCULATE_DOCS";
|
case PacketType::RECALCULATE_DOCS: return "RECALCULATE_DOCS";
|
||||||
case PacketType::GET_DOCS: return "GET_DOCS";
|
case PacketType::GET_DOCS: return "GET_DOCS";
|
||||||
case PacketType::SEND_HASH: return "SEND_HASH";
|
case PacketType::SEND_HASH: return "SEND_HASH";
|
||||||
case PacketType::TYPE_CFIUPDATE: return "CFI_UPDATE";
|
case PacketType::TYPE_UPDATEDCFI: return "UPDATED_CFI";
|
||||||
|
|
||||||
default: return "Unknown";
|
default: return "Unknown";
|
||||||
|
|
||||||
|
|||||||
@@ -249,7 +249,7 @@ void CommonClientHandler::slot_DocsChanged()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommonClientHandler::sendXmlAnswer(QByteArray array)
|
void CommonClientHandler::sendUpdatedCFI(QByteArray array)
|
||||||
{
|
{
|
||||||
foreach(int idSocket, clientsMap->keys())
|
foreach(int idSocket, clientsMap->keys())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public:
|
|||||||
|
|
||||||
void slot_DocsChanged();
|
void slot_DocsChanged();
|
||||||
|
|
||||||
void sendXmlAnswer(QByteArray array);
|
void sendUpdatedCFI(QByteArray array);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void slot_sendPacketToAllClients(PacketType packetType, bool flOnlyGUI);
|
void slot_sendPacketToAllClients(PacketType packetType, bool flOnlyGUI);
|
||||||
|
|||||||
@@ -266,7 +266,7 @@ void ProcessingSystem::processingCFIUpdate(QByteArray array)
|
|||||||
|
|
||||||
cfiController->unLockAccessToCfiXML();
|
cfiController->unLockAccessToCfiXML();
|
||||||
|
|
||||||
commonClientServer->sendXmlAnswer(result);
|
commonClientServer->sendUpdatedCFI(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcessingSystem::processingEntryUnityClient(ClientHandler *client)
|
void ProcessingSystem::processingEntryUnityClient(ClientHandler *client)
|
||||||
@@ -652,7 +652,7 @@ void ProcessingSystem::processingClientQueryTasksXML(ClientHandler *client, Clie
|
|||||||
nameFile = tasksFIMfileName;
|
nameFile = tasksFIMfileName;
|
||||||
pathFile = updateController->getPathAdditionalFile(nameFile);
|
pathFile = updateController->getPathAdditionalFile(nameFile);
|
||||||
Logger::instance().log(pathFile);
|
Logger::instance().log(pathFile);
|
||||||
client->sendFileBlock(pathFile);
|
client->sendFileBlock_forGUI(pathFile);
|
||||||
client->sendPacketType(PacketType::TYPE_XMLANSWER_QUERY_TASKS_XML_FIM);
|
client->sendPacketType(PacketType::TYPE_XMLANSWER_QUERY_TASKS_XML_FIM);
|
||||||
}
|
}
|
||||||
else if(clientQueryTasksXML.Type == "amm")
|
else if(clientQueryTasksXML.Type == "amm")
|
||||||
@@ -660,7 +660,7 @@ void ProcessingSystem::processingClientQueryTasksXML(ClientHandler *client, Clie
|
|||||||
nameFile = tasksAMMfileName;
|
nameFile = tasksAMMfileName;
|
||||||
pathFile = updateController->getPathAdditionalFile(nameFile);
|
pathFile = updateController->getPathAdditionalFile(nameFile);
|
||||||
docsUpdater->lockAccessToDocsXML();
|
docsUpdater->lockAccessToDocsXML();
|
||||||
client->sendFileBlock(pathFile);
|
client->sendFileBlock_forGUI(pathFile);
|
||||||
client->sendPacketType(PacketType::TYPE_XMLANSWER_QUERY_TASKS_XML_AMM);
|
client->sendPacketType(PacketType::TYPE_XMLANSWER_QUERY_TASKS_XML_AMM);
|
||||||
docsUpdater->unLockAccessToDocsXML();
|
docsUpdater->unLockAccessToDocsXML();
|
||||||
}
|
}
|
||||||
@@ -735,6 +735,13 @@ void ProcessingSystem::processingClientNotify(ClientHandler *client, ClientNotif
|
|||||||
{
|
{
|
||||||
chatSystem->sendOldMessages(clientData->getId());
|
chatSystem->sendOldMessages(clientData->getId());
|
||||||
}
|
}
|
||||||
|
else if (clientNotify.Code == commandGetCFI)
|
||||||
|
{
|
||||||
|
QByteArray result;
|
||||||
|
QString path = updateController->getPathAdditionalFile(cfiListFileName);
|
||||||
|
Tools::loadFileXMLtoByteArray(path,result);
|
||||||
|
client->sendXmlAnswer(result,PacketType::TYPE_UPDATEDCFI);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcessingSystem::setCurrentDataInfo(DataInfo *dataInfo)
|
void ProcessingSystem::setCurrentDataInfo(DataInfo *dataInfo)
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
#include "recognizesystem.h"
|
#include "recognizesystem.h"
|
||||||
|
|
||||||
RecognizeSystem::RecognizeSystem(QObject *parent):
|
RecognizeSystem::RecognizeSystem(QObject *parent):
|
||||||
QObject(parent)
|
QObject(parent),
|
||||||
|
globalMutex(nullptr)
|
||||||
{
|
{
|
||||||
packetType = PacketType::TYPE_NONE;
|
packetType = PacketType::TYPE_NONE;
|
||||||
filePath.clear();
|
filePath.clear();
|
||||||
@@ -13,7 +14,7 @@ QObject(parent)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RecognizeSystem::initialize(UpdateController *updateController,DataParser* dataParser,SendSystem *sendSystem, ClientHandler *handler)
|
void RecognizeSystem::initialize(UpdateController *updateController,DataParser* dataParser, QMutex *globalMutex,SendSystem *sendSystem, ClientHandler *handler)
|
||||||
{
|
{
|
||||||
qDebug() << "RecognizeSystem::initialize thread ID " << QThread::currentThreadId();
|
qDebug() << "RecognizeSystem::initialize thread ID " << QThread::currentThreadId();
|
||||||
|
|
||||||
@@ -22,6 +23,7 @@ void RecognizeSystem::initialize(UpdateController *updateController,DataParser*
|
|||||||
this->clientHandler = handler;
|
this->clientHandler = handler;
|
||||||
this->sendSystem = sendSystem;
|
this->sendSystem = sendSystem;
|
||||||
socket = handler->getSocket();
|
socket = handler->getSocket();
|
||||||
|
this->globalMutex = globalMutex;
|
||||||
|
|
||||||
connect(this,&RecognizeSystem::sigCalculateHash,updateController,&UpdateController::calculateFullHashWithSetup,Qt::AutoConnection);
|
connect(this,&RecognizeSystem::sigCalculateHash,updateController,&UpdateController::calculateFullHashWithSetup,Qt::AutoConnection);
|
||||||
connect(this,&RecognizeSystem::sigChangeVersion,updateController,&UpdateController::changeAssetVersion,Qt::AutoConnection);
|
connect(this,&RecognizeSystem::sigChangeVersion,updateController,&UpdateController::changeAssetVersion,Qt::AutoConnection);
|
||||||
@@ -29,7 +31,7 @@ void RecognizeSystem::initialize(UpdateController *updateController,DataParser*
|
|||||||
connect(this,&RecognizeSystem::sigCopyVersion,updateController,&UpdateController::createCopyVersion,Qt::AutoConnection);
|
connect(this,&RecognizeSystem::sigCopyVersion,updateController,&UpdateController::createCopyVersion,Qt::AutoConnection);
|
||||||
connect(this,&RecognizeSystem::sigXmlParser,dataParser->getProcessParser(),&ProcessParser::slot_read,Qt::AutoConnection);
|
connect(this,&RecognizeSystem::sigXmlParser,dataParser->getProcessParser(),&ProcessParser::slot_read,Qt::AutoConnection);
|
||||||
//connect(this,&RecognizeSystem::sigRecalculateDocs,server,&ServerLMSWidget::slot_UpdateDocs,Qt::AutoConnection);
|
//connect(this,&RecognizeSystem::sigRecalculateDocs,server,&ServerLMSWidget::slot_UpdateDocs,Qt::AutoConnection);
|
||||||
connect(this,&RecognizeSystem::sigSendDocs,sendSystem,&SendSystem::sendDocs,Qt::AutoConnection);
|
connect(this,&RecognizeSystem::sigSendDocs_forQtClient,sendSystem,&SendSystem::slot_sendDocs_forQtClient,Qt::AutoConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RecognizeSystem::recognize()
|
void RecognizeSystem::recognize()
|
||||||
@@ -403,7 +405,7 @@ void RecognizeSystem::recognize()
|
|||||||
|
|
||||||
if (updateController->checkDuplicate(result[1]))
|
if (updateController->checkDuplicate(result[1]))
|
||||||
{
|
{
|
||||||
sendSystem->sendNotify(commandDuplicateVerName);
|
sendSystem->slot_sendNotify(commandDuplicateVerName);
|
||||||
packetType = PacketType::TYPE_NONE;
|
packetType = PacketType::TYPE_NONE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -425,11 +427,11 @@ void RecognizeSystem::recognize()
|
|||||||
|
|
||||||
if (versionName == baseNameVersion)
|
if (versionName == baseNameVersion)
|
||||||
{
|
{
|
||||||
sendSystem->sendNotify(commandTryBaseDelete);
|
sendSystem->slot_sendNotify(commandTryBaseDelete);
|
||||||
}
|
}
|
||||||
else if (versionName == updateController->getCurrentVersionName())
|
else if (versionName == updateController->getCurrentVersionName())
|
||||||
{
|
{
|
||||||
sendSystem->sendNotify(commandTryActiveDelete);
|
sendSystem->slot_sendNotify(commandTryActiveDelete);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -452,7 +454,7 @@ void RecognizeSystem::recognize()
|
|||||||
|
|
||||||
if(packetType == PacketType::GET_DOCS)
|
if(packetType == PacketType::GET_DOCS)
|
||||||
{
|
{
|
||||||
emit sigSendDocs(updateController->getPathAdditionalFile(tasksAMMfileName));
|
emit sigSendDocs_forQtClient(updateController->getPathAdditionalFile(tasksAMMfileName));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (packetType == PacketType::SEND_HASH)
|
if (packetType == PacketType::SEND_HASH)
|
||||||
@@ -509,11 +511,6 @@ void RecognizeSystem::recognize()
|
|||||||
packetType = PacketType::TYPE_NONE;
|
packetType = PacketType::TYPE_NONE;
|
||||||
client->setClientHash(hash);
|
client->setClientHash(hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(packetType == PacketType::TYPE_CFIUPDATE)
|
|
||||||
{
|
|
||||||
qDebug() << "CFI HELLO";
|
|
||||||
}
|
|
||||||
packetType = PacketType::TYPE_NONE;
|
packetType = PacketType::TYPE_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class RecognizeSystem : public QObject
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
RecognizeSystem(QObject *parent = nullptr);
|
RecognizeSystem(QObject *parent = nullptr);
|
||||||
void initialize(UpdateController *updateController,DataParser *dataParser, SendSystem *sendSystem, ClientHandler *handler);
|
void initialize(UpdateController *updateController,DataParser *dataParser, QMutex *globalMutex, SendSystem *sendSystem, ClientHandler *handler);
|
||||||
void recognize();
|
void recognize();
|
||||||
~RecognizeSystem();
|
~RecognizeSystem();
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ signals:
|
|||||||
void sigDeleteVersion(QString versionName);
|
void sigDeleteVersion(QString versionName);
|
||||||
void sigCopyVersion(QString versionName,QString newVersionName,QString author);
|
void sigCopyVersion(QString versionName,QString newVersionName,QString author);
|
||||||
//void sigRecalculateDocs();
|
//void sigRecalculateDocs();
|
||||||
void sigSendDocs(QString docsPath);
|
void sigSendDocs_forQtClient(QString docsPath);
|
||||||
|
|
||||||
void signal_updateDocsXML();
|
void signal_updateDocsXML();
|
||||||
|
|
||||||
@@ -47,6 +47,7 @@ private:
|
|||||||
QString filePath;
|
QString filePath;
|
||||||
ClientHandler *clientHandler;
|
ClientHandler *clientHandler;
|
||||||
QMutex *mutex;
|
QMutex *mutex;
|
||||||
|
QMutex *globalMutex;
|
||||||
|
|
||||||
QTcpSocket *socket;
|
QTcpSocket *socket;
|
||||||
|
|
||||||
|
|||||||
@@ -1,88 +1,370 @@
|
|||||||
#include "sendsystem.h"
|
#include "sendsystem.h"
|
||||||
|
|
||||||
SendSystem::SendSystem(QObject *parent) : QObject(parent)
|
SendSystem::SendSystem(QObject *parent) :
|
||||||
|
QObject(parent),
|
||||||
|
client(nullptr),
|
||||||
|
socket(nullptr),
|
||||||
|
dataParser(nullptr),
|
||||||
|
globalMutex(nullptr),
|
||||||
|
buffer(nullptr),
|
||||||
|
type(TypeClientAutorization::TYPE_GUI),
|
||||||
|
flSendingStopped(false),
|
||||||
|
flWaitWritenToSocket(false),
|
||||||
|
bytesWritedToSocket(0),
|
||||||
|
fileSize(0),
|
||||||
|
countSend(0)
|
||||||
{
|
{
|
||||||
isSendStopped = false;
|
qDebug() << "SendSystem init thread ID " << QThread::currentThreadId();
|
||||||
|
|
||||||
|
buffer = new char[sendFileBlockSize];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SendSystem::~SendSystem()
|
||||||
|
{
|
||||||
|
delete buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void SendSystem::initialize(DataParser *dataParser, QMutex *globalMutex)
|
void SendSystem::initialize(DataParser *dataParser, QMutex *globalMutex)
|
||||||
{
|
{
|
||||||
qDebug() << "SendSystem::initialize thread ID " << QThread::currentThreadId();
|
qDebug() << "SendSystem::initialize thread ID " << QThread::currentThreadId();
|
||||||
|
|
||||||
this->dataParser = dataParser;
|
this->dataParser = dataParser;
|
||||||
//connect(this,&SendSystem::sigSendXMLmessage,dataParser->ClientAnswer(),&ClientAnswerParser::message,Qt::AutoConnection); //сигнал не используется
|
this->globalMutex = globalMutex;
|
||||||
connect(this,&SendSystem::sigSendNotify,dataParser->ClientAnswer(),&ClientAnswerParser::notify,Qt::DirectConnection); //потому что возвращает значение
|
|
||||||
//connect(this,&SendSystem::sigSendVersion,dataParser->ClientAnswer(),&ClientAnswerParser::currentVersion,Qt::AutoConnection); //сигнал не используется
|
|
||||||
|
|
||||||
mutex = globalMutex;
|
connect(this, &SendSystem::sigSendNotify, dataParser->ClientAnswer(), &ClientAnswerParser::notify, Qt::DirectConnection); //потому что возвращает значение
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendSystem::setClient(Client *client, QTcpSocket *socket)
|
void SendSystem::setClient(Client *client, QTcpSocket *socket)
|
||||||
{
|
{
|
||||||
|
qDebug() << "SendSystem::setClient thread ID " << QThread::currentThreadId();
|
||||||
|
|
||||||
this->socket = socket;
|
this->socket = socket;
|
||||||
this->type = client->getClientType();
|
|
||||||
this->client = client;
|
this->client = client;
|
||||||
isSendStopped = false;
|
|
||||||
|
this->type = client->getClientType();
|
||||||
|
|
||||||
|
flSendingStopped = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendSystem::sendNotify(QString notify)
|
void SendSystem::updateFiles(QList<FileData> fileSendList, QList<FileData> deleteList)
|
||||||
{
|
{
|
||||||
qDebug() << "SendSystem::sendNotify thread ID " << QThread::currentThreadId();
|
QListIterator<FileData> clientIterator(deleteList);
|
||||||
|
|
||||||
|
while(clientIterator.hasNext())
|
||||||
|
{
|
||||||
|
FileData data = clientIterator.next();
|
||||||
|
|
||||||
|
slot_sendDeleteBlock(data.path);
|
||||||
|
if(slot_getIsSendingStopped())
|
||||||
|
{
|
||||||
|
Logger::instance().log("Client: " + client->getLogin() + " isSendStopped", LogLevel::ERROR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QListIterator<FileData> serverIterator(fileSendList);
|
||||||
|
|
||||||
|
while(serverIterator.hasNext())
|
||||||
|
{
|
||||||
|
FileData data = serverIterator.next();
|
||||||
|
|
||||||
|
if (data.hash == "FOLDER")
|
||||||
|
{
|
||||||
|
slot_sendFolderBlock(data.path);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
slot_sendFileBlock_forQtClient(data.path);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(slot_getIsSendingStopped())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
slot_sendPacketType(PacketType::UPDATE_FILES_COMPLETE);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SendSystem::waitWrittenData(QString marker, int msec)
|
||||||
|
{
|
||||||
|
bool success = socket->waitForBytesWritten(msec);
|
||||||
|
if(success)
|
||||||
|
{
|
||||||
|
//qInfo() << "Data sended OK. <" + marker + ">";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug() << "WaitForBytesWritten timeout. <" + marker + ">";
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SendSystem::slot_BytesWrittenToSocket(qint64 bytes)
|
||||||
|
{
|
||||||
|
flWaitWritenToSocket = false;
|
||||||
|
bytesWritedToSocket = bytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SendSystem::slot_getIsSendingStopped() const
|
||||||
|
{
|
||||||
|
return flSendingStopped;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SendSystem::slot_stopSending()
|
||||||
|
{
|
||||||
|
flSendingStopped = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SendSystem::slot_socketClose()
|
||||||
|
{
|
||||||
|
socket->close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SendSystem::slot_sendVersion()
|
||||||
|
{
|
||||||
|
QByteArray data = dataParser->ClientAnswer()->currentVersion();
|
||||||
|
slot_sendXmlAnswer(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SendSystem::slot_sendNotify(QString notify)
|
||||||
|
{
|
||||||
auto answer = emit sigSendNotify(notify);
|
auto answer = emit sigSendNotify(notify);
|
||||||
sendXmlAnswer(answer);
|
slot_sendXmlAnswer(answer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendSystem::sendFileBlock(QString path)
|
void SendSystem::slot_sendPacketType(PacketType packetType)
|
||||||
{
|
{
|
||||||
QFile file(path);
|
Logger::instance().log(" SEND TO: " + client->getLogin() + " " + enumToString(packetType), LogLevel::DEBUG);
|
||||||
QFileInfo fileInfo(file);
|
if (client->getClientType() == TypeClientAutorization::TYPE_QT_CLIENT ||
|
||||||
|
client->getClientType() == TypeClientAutorization::TYPE_GUI)
|
||||||
|
{
|
||||||
|
QDataStream stream(socket);
|
||||||
|
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
||||||
|
stream << packetType;
|
||||||
|
|
||||||
if(isSendStopped)
|
waitWrittenData("sendPacketType");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QByteArray message;
|
||||||
|
int type = (int)packetType;
|
||||||
|
message.append(reinterpret_cast<char*>(&type), sizeof(int));
|
||||||
|
socket->write(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SendSystem::slot_sendXmlAnswer(QByteArray array, PacketType packetType)
|
||||||
|
{
|
||||||
|
Logger::instance().log("SEND TO: "+ client->getLogin() + " " + enumToString(packetType) + "\n Text: " +
|
||||||
|
QString(array), LogLevel::DEBUG);
|
||||||
|
|
||||||
|
if (client->getClientType() == TypeClientAutorization::TYPE_QT_CLIENT ||
|
||||||
|
client->getClientType() == TypeClientAutorization::TYPE_GUI)
|
||||||
|
{
|
||||||
|
QDataStream stream(socket);
|
||||||
|
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
||||||
|
|
||||||
|
stream << packetType;
|
||||||
|
stream << array;
|
||||||
|
|
||||||
|
waitWrittenData("sendXmlAnswer");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
slot_sendPacketType(packetType);
|
||||||
|
QByteArray message;
|
||||||
|
int size = array.length();
|
||||||
|
message.append(reinterpret_cast<char*>(&size), sizeof(int));
|
||||||
|
socket->write(message);
|
||||||
|
socket->write(array);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SendSystem::slot_sendDocs_forQtClient(QString docsPath)
|
||||||
|
{
|
||||||
|
slot_sendFileBlock_forQtClient(docsPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SendSystem::slot_sendNeedUpdate(bool flag, quint64 size, quint64 fileCount, quint64 deleteCount)
|
||||||
|
{
|
||||||
|
QDataStream stream(socket);
|
||||||
|
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
||||||
|
stream << PacketType::TYPE_NEEDUPDATE;
|
||||||
|
stream << flag;
|
||||||
|
stream << size;
|
||||||
|
stream << fileCount;
|
||||||
|
stream << deleteCount;
|
||||||
|
|
||||||
|
waitWrittenData("sendNeedUpdate");
|
||||||
|
}
|
||||||
|
|
||||||
|
void SendSystem::slot_sendFolderBlock(QString path)
|
||||||
|
{
|
||||||
|
QDataStream stream(socket);
|
||||||
|
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
||||||
|
|
||||||
|
stream << PacketType::TYPE_FOLDER;
|
||||||
|
stream << path;
|
||||||
|
|
||||||
|
waitWrittenData("sendFolderBlock");
|
||||||
|
}
|
||||||
|
|
||||||
|
void SendSystem::slot_sendDeleteBlock(QString path)
|
||||||
|
{
|
||||||
|
QDataStream stream(socket);
|
||||||
|
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
||||||
|
|
||||||
|
stream << PacketType::TYPE_DELETE;
|
||||||
|
stream << path;
|
||||||
|
|
||||||
|
waitWrittenData("sendDeleteBlock");
|
||||||
|
}
|
||||||
|
|
||||||
|
void SendSystem::slot_sendFileBlock_forGUI(QString path)
|
||||||
|
{
|
||||||
|
//qDebug() << "SendSystem::sendFileBlock path: " << path;
|
||||||
|
|
||||||
|
if(slot_getIsSendingStopped())
|
||||||
{ //Поведение на случай отключения клиента
|
{ //Поведение на случай отключения клиента
|
||||||
file.close();
|
Logger::instance().log("Client: " + client->getLogin() + " isSendingStopped", LogLevel::ERROR);
|
||||||
Logger::instance().log("UNLOCK STOP MUTEX : " + client->getLogin(),LogLevel::ERROR);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDataStream stream(socket);
|
QFile file(path);
|
||||||
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
QFileInfo fileInfo(file);
|
||||||
|
|
||||||
fileSize = file.size();
|
fileSize = file.size();
|
||||||
|
|
||||||
if (fileSize == 0)
|
if (fileSize == 0)
|
||||||
{
|
{
|
||||||
Logger::instance().log("Client: " + client->getLogin() + " WARNING! Zero size " + fileInfo.fileName(),LogLevel::ERROR);
|
Logger::instance().log("Client: " + client->getLogin() + " ERROR! File zero size " + fileInfo.fileName(), LogLevel::ERROR);
|
||||||
Logger::instance().log(path, LogLevel::ERROR);
|
Logger::instance().log(path, LogLevel::ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
stream << PacketType::TYPE_FILE; //Отправляем тип блока
|
if(!file.open(QFile::ReadOnly))
|
||||||
stream << path << fileSize;
|
|
||||||
|
|
||||||
if(file.open(QFile::ReadOnly))
|
|
||||||
{
|
{
|
||||||
while(!file.atEnd())
|
Logger::instance().log("Client: " + client->getLogin() + " ERROR! File not open: " + fileInfo.fileName(), LogLevel::ERROR);
|
||||||
{
|
Logger::instance().log(path, LogLevel::ERROR);
|
||||||
QByteArray data = file.read(sendFileBlockSize);
|
return;
|
||||||
stream << data;
|
|
||||||
//socket->waitForBytesWritten(10);
|
|
||||||
|
|
||||||
if(socket->state() == QAbstractSocket::UnconnectedState) break;
|
|
||||||
countSend++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//emit sigSendToLogger(Tools::getTime() + " send file " + fileInfo.fileName());
|
countSend = 0;
|
||||||
|
|
||||||
|
QDataStream stream(socket);
|
||||||
|
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
||||||
|
|
||||||
|
stream << PacketType::TYPE_FILE;
|
||||||
|
stream << path << fileSize;
|
||||||
|
|
||||||
|
waitWrittenData("sendFileBlock:header " + fileInfo.fileName());
|
||||||
|
|
||||||
|
while(!file.atEnd())
|
||||||
|
{
|
||||||
|
if(socket->state() == QAbstractSocket::UnconnectedState)
|
||||||
|
{
|
||||||
|
Logger::instance().log("Client: " + client->getLogin() + " UnconnectedState", LogLevel::ERROR);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray data = file.read(sendFileBlockSize);
|
||||||
|
stream << data;
|
||||||
|
|
||||||
|
waitWrittenData(QString("sendFileBlock:data (size %1) ").arg(data.size()) + fileInfo.fileName());
|
||||||
|
|
||||||
|
countSend++;
|
||||||
}
|
}
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
countSend = 0;
|
countSend = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendSystem::sendFileBlockByteArray(QByteArray array, PacketType packetType)
|
void SendSystem::slot_sendFileBlock_forQtClient(QString path)
|
||||||
{
|
{
|
||||||
if(client->getClientType() == TypeClientAutorization::TYPE_QT_CLIENT ||
|
//qDebug() << "SendSystem::sendFileBlock path: " << path;
|
||||||
client->getClientType() == TypeClientAutorization::TYPE_GUI)
|
|
||||||
|
if(slot_getIsSendingStopped())
|
||||||
|
{ //Поведение на случай отключения клиента
|
||||||
|
Logger::instance().log("Client: " + client->getLogin() + " isSendingStopped", LogLevel::ERROR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QFile file(path);
|
||||||
|
QFileInfo fileInfo(file);
|
||||||
|
|
||||||
|
fileSize = file.size();
|
||||||
|
|
||||||
|
if (fileSize == 0)
|
||||||
|
{
|
||||||
|
Logger::instance().log("Client: " + client->getLogin() + " ERROR! File zero size " + fileInfo.fileName(), LogLevel::ERROR);
|
||||||
|
Logger::instance().log(path, LogLevel::ERROR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!file.open(QFile::ReadOnly))
|
||||||
|
{
|
||||||
|
Logger::instance().log("Client: " + client->getLogin() + " ERROR! File not open: " + fileInfo.fileName(), LogLevel::ERROR);
|
||||||
|
Logger::instance().log(path, LogLevel::ERROR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
countSend = 0;
|
||||||
|
|
||||||
|
QDataStream stream(socket);
|
||||||
|
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
||||||
|
|
||||||
|
stream << PacketType::TYPE_FILE;
|
||||||
|
stream << path << fileSize;
|
||||||
|
|
||||||
|
waitWrittenData("sendFileBlock:header " + fileInfo.fileName());
|
||||||
|
|
||||||
|
connect(this->socket, &QTcpSocket::bytesWritten, this, &SendSystem::slot_BytesWrittenToSocket);
|
||||||
|
|
||||||
|
while(!file.atEnd())
|
||||||
|
{
|
||||||
|
if(socket->state() == QAbstractSocket::UnconnectedState)
|
||||||
|
{
|
||||||
|
Logger::instance().log("Client: " + client->getLogin() + " UnconnectedState", LogLevel::ERROR);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
qint64 readBytes = file.read(buffer, sendFileBlockSize);
|
||||||
|
if(readBytes <= 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
flWaitWritenToSocket = true;
|
||||||
|
|
||||||
|
while(!socket->write(buffer, readBytes))
|
||||||
|
{
|
||||||
|
qCritical() << "socket->write ERROR. size " + QString::number(readBytes);
|
||||||
|
int i = 0;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
while(flWaitWritenToSocket)
|
||||||
|
{
|
||||||
|
QCoreApplication::processEvents(); // Обеспечиваем обработку сообщений
|
||||||
|
int i = 0;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
waitWrittenData(QString("sendFileBlock:data (readBytes %1, num %2) ").arg(QString::number(readBytes), QString::number(countSend)) + fileInfo.fileName());
|
||||||
|
|
||||||
|
countSend++;
|
||||||
|
}
|
||||||
|
|
||||||
|
disconnect(this->socket, &QTcpSocket::bytesWritten, this, &SendSystem::slot_BytesWrittenToSocket);
|
||||||
|
|
||||||
|
file.close();
|
||||||
|
countSend = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SendSystem::slot_sendFileBlockByteArray(QByteArray array, PacketType packetType)
|
||||||
|
{
|
||||||
|
if(client->getClientType() == TypeClientAutorization::TYPE_GUI)
|
||||||
{
|
{
|
||||||
QDataStream stream(socket);
|
QDataStream stream(socket);
|
||||||
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
||||||
@@ -99,17 +381,52 @@ void SendSystem::sendFileBlockByteArray(QByteArray array, PacketType packetType)
|
|||||||
stream << packetType; //Отправляем тип блока
|
stream << packetType; //Отправляем тип блока
|
||||||
stream << size;
|
stream << size;
|
||||||
|
|
||||||
|
waitWrittenData("sendFileBlockByteArray");
|
||||||
|
|
||||||
while (bytesSended < size)
|
while (bytesSended < size)
|
||||||
{
|
{
|
||||||
QByteArray chunk = array.mid(bytesSended, sendFileBlockSize);
|
QByteArray chunk = array.mid(bytesSended, sendFileBlockSize);
|
||||||
stream << chunk;
|
stream << chunk;
|
||||||
|
//bytesSended = socket->write(chunk);
|
||||||
|
|
||||||
|
waitWrittenData("sendFileBlockByteArray");
|
||||||
|
|
||||||
|
bytesSended += chunk.length();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(client->getClientType() == TypeClientAutorization::TYPE_QT_CLIENT)
|
||||||
|
{
|
||||||
|
QDataStream stream(socket);
|
||||||
|
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
||||||
|
|
||||||
|
qint64 size = array.size();
|
||||||
|
qint64 bytesSended = 0;
|
||||||
|
|
||||||
|
if (size == 0)
|
||||||
|
{
|
||||||
|
Logger::instance().log(" WARNING! Zero size ",LogLevel::ERROR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
stream << packetType; //Отправляем тип блока
|
||||||
|
stream << size;
|
||||||
|
|
||||||
|
waitWrittenData("sendFileBlockByteArray");
|
||||||
|
|
||||||
|
while (bytesSended < size)
|
||||||
|
{
|
||||||
|
QByteArray chunk = array.mid(bytesSended, sendFileBlockSize);
|
||||||
|
//stream << chunk;
|
||||||
|
bytesSended = socket->write(chunk);
|
||||||
|
|
||||||
|
waitWrittenData("sendFileBlockByteArray");
|
||||||
|
|
||||||
bytesSended += chunk.length();
|
bytesSended += chunk.length();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sendPacketType(packetType);
|
slot_sendPacketType(packetType);
|
||||||
qint64 size = array.size();
|
qint64 size = array.size();
|
||||||
qint64 bytesSended = 0;
|
qint64 bytesSended = 0;
|
||||||
|
|
||||||
@@ -134,206 +451,86 @@ void SendSystem::sendFileBlockByteArray(QByteArray array, PacketType packetType)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendSystem::sendVersion()
|
void SendSystem::slot_sendFileBlockWithRename_Hash_forQtClient(QString path, QString newName)
|
||||||
{
|
{
|
||||||
QByteArray data = dataParser->ClientAnswer()->currentVersion();
|
//qDebug() << "SendSystem::sendFileBlockWithRename thread ID " << QThread::currentThreadId();
|
||||||
sendXmlAnswer(data);
|
|
||||||
|
if(slot_getIsSendingStopped())
|
||||||
|
{ //Поведение на случай отключения клиента
|
||||||
|
Logger::instance().log("Client: " + client->getLogin() + " isSendingStopped", LogLevel::ERROR);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendSystem::sendFileBlockWithRename(QString path, QString newName)
|
|
||||||
{
|
|
||||||
qDebug() << "SendSystem::sendFileBlockWithRename thread ID " << QThread::currentThreadId();
|
|
||||||
|
|
||||||
QDataStream stream(socket);
|
|
||||||
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
|
||||||
|
|
||||||
QFile file(Tools::createRootPath(path));
|
QFile file(Tools::createRootPath(path));
|
||||||
QFileInfo fileInfo(file);
|
QFileInfo fileInfo(file);
|
||||||
fileSize = fileInfo.size();
|
fileSize = fileInfo.size();
|
||||||
|
|
||||||
if(fileSize == 0){
|
if (fileSize == 0)
|
||||||
Logger::instance().log("Client: " + client->getLogin() + " WARNING! Zero size " + fileInfo.fileName(),LogLevel::ERROR);
|
{
|
||||||
|
Logger::instance().log("Client: " + client->getLogin() + " ERROR! File zero size " + fileInfo.fileName(), LogLevel::ERROR);
|
||||||
|
Logger::instance().log(path, LogLevel::ERROR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!file.open(QFile::ReadOnly))
|
||||||
|
{
|
||||||
|
Logger::instance().log("Client: " + client->getLogin() + " ERROR! File not open: " + fileInfo.fileName(), LogLevel::ERROR);
|
||||||
|
Logger::instance().log(path, LogLevel::ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString pathForSend = Tools::createFolderPath(path) + "/" + staticDataFolderName + newName;
|
QString pathForSend = Tools::createFolderPath(path) + "/" + staticDataFolderName + newName;
|
||||||
|
|
||||||
stream << PacketType::TYPE_FILE; //Отправляем тип блока
|
countSend = 0;
|
||||||
|
|
||||||
|
QDataStream stream(socket);
|
||||||
|
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
||||||
|
|
||||||
|
stream << PacketType::TYPE_FILE;
|
||||||
stream << pathForSend << fileSize;
|
stream << pathForSend << fileSize;
|
||||||
|
|
||||||
if(isSendStopped) { //Поведение на случай отключения клиента
|
waitWrittenData("sendFileBlockWithRename");
|
||||||
|
|
||||||
file.close();
|
connect(this->socket, &QTcpSocket::bytesWritten, this, &SendSystem::slot_BytesWrittenToSocket);
|
||||||
return;
|
|
||||||
|
while(!file.atEnd())
|
||||||
|
{
|
||||||
|
if(socket->state() == QAbstractSocket::UnconnectedState)
|
||||||
|
{
|
||||||
|
Logger::instance().log("Client: " + client->getLogin() + " UnconnectedState", LogLevel::ERROR);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qint64 readBytes = file.read(buffer, sendFileBlockSize);
|
||||||
|
if(readBytes <= 0)
|
||||||
|
break;
|
||||||
|
|
||||||
socket->waitForBytesWritten();
|
flWaitWritenToSocket = true;
|
||||||
|
|
||||||
|
while(!socket->write(buffer, readBytes))
|
||||||
|
{
|
||||||
|
qCritical() << "socket->write ERROR. size " + QString::number(readBytes);
|
||||||
|
int i = 0;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
while(flWaitWritenToSocket)
|
||||||
|
{
|
||||||
|
QCoreApplication::processEvents(); // Обеспечиваем обработку сообщений
|
||||||
|
int i = 0;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
waitWrittenData(QString("sendFileBlock:data (readBytes %1, num %2) ").arg(QString::number(readBytes), QString::number(countSend)) + fileInfo.fileName());
|
||||||
|
|
||||||
if(file.open(QFile::ReadOnly)){
|
|
||||||
while(!file.atEnd()){
|
|
||||||
QByteArray data = file.read(sendFileBlockSize);
|
|
||||||
stream << data;
|
|
||||||
socket->waitForBytesWritten();
|
|
||||||
countSend++;
|
countSend++;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::instance().log("Send file " + fileInfo.fileName());
|
disconnect(this->socket, &QTcpSocket::bytesWritten, this, &SendSystem::slot_BytesWrittenToSocket);
|
||||||
}
|
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
countSend = 0;
|
countSend = 0;
|
||||||
socket->waitForBytesWritten();
|
//waitWrittenData("sendFileBlockWithRename");
|
||||||
socket->waitForReadyRead(100);
|
//socket->waitForReadyRead(100);
|
||||||
|
|
||||||
sendNotify(commandHashCompleteClient);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SendSystem::sendFolderBlock(QString path)
|
|
||||||
{
|
|
||||||
QDataStream stream(socket);
|
|
||||||
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
|
||||||
|
|
||||||
stream << PacketType::TYPE_FOLDER;
|
|
||||||
stream << path;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SendSystem::sendDeleteBlock(QString path)
|
|
||||||
{
|
|
||||||
QDataStream stream(socket);
|
|
||||||
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
|
||||||
|
|
||||||
stream << PacketType::TYPE_DELETE;
|
|
||||||
stream << path;
|
|
||||||
qDebug() << "DELETE: " + path;
|
|
||||||
socket->waitForReadyRead(10);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SendSystem::sendPacketType(PacketType packetType)
|
|
||||||
{
|
|
||||||
Logger::instance().log(" SEND TO: " + client->getLogin() + " " + enumToString(packetType), LogLevel::DEBUG);
|
|
||||||
if (client->getClientType() == TypeClientAutorization::TYPE_QT_CLIENT ||
|
|
||||||
client->getClientType() == TypeClientAutorization::TYPE_GUI)
|
|
||||||
{
|
|
||||||
|
|
||||||
QDataStream stream(socket);
|
|
||||||
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
|
||||||
stream << packetType;
|
|
||||||
socket->waitForReadyRead(100);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
QByteArray message;
|
|
||||||
int type = (int)packetType;
|
|
||||||
message.append(reinterpret_cast<char*>(&type), sizeof(int));
|
|
||||||
socket->write(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void SendSystem::sendXmlAnswer(QByteArray array, PacketType packetType)
|
|
||||||
{
|
|
||||||
qDebug() << "SendSystem::sendXmlAnswer thread ID " << QThread::currentThreadId();
|
|
||||||
|
|
||||||
Logger::instance().log("SEND TO: "+ client->getLogin() + " " + enumToString(packetType) + "\n Text: " +
|
|
||||||
QString(array),LogLevel::DEBUG);
|
|
||||||
|
|
||||||
if (client->getClientType() == TypeClientAutorization::TYPE_QT_CLIENT ||
|
|
||||||
client->getClientType() == TypeClientAutorization::TYPE_GUI)
|
|
||||||
{
|
|
||||||
QDataStream stream(socket);
|
|
||||||
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
|
||||||
|
|
||||||
stream << packetType;
|
|
||||||
stream << array;
|
|
||||||
socket->waitForBytesWritten();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sendPacketType(packetType);
|
|
||||||
QByteArray message;
|
|
||||||
int size = array.length();
|
|
||||||
message.append(reinterpret_cast<char*>(&size), sizeof(int));
|
|
||||||
socket->write(message);
|
|
||||||
socket->write(array);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SendSystem::sendNeedUpdate(bool flag,quint64 size,quint64 fileCount,quint64 deleteCount)
|
|
||||||
{
|
|
||||||
QDataStream stream(socket);
|
|
||||||
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
|
||||||
stream << PacketType::TYPE_NEEDUPDATE;
|
|
||||||
stream << flag;
|
|
||||||
stream << size;
|
|
||||||
stream << fileCount;
|
|
||||||
stream << deleteCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SendSystem::updateFiles(QList<FileData> fileSendList, QList<FileData> deleteList){
|
|
||||||
|
|
||||||
QMutexLocker locker(mutex);
|
|
||||||
QListIterator<FileData> clientIterator(deleteList);
|
|
||||||
|
|
||||||
while(clientIterator.hasNext())
|
|
||||||
{
|
|
||||||
FileData data = clientIterator.next();
|
|
||||||
|
|
||||||
sendDeleteBlock(data.path);
|
|
||||||
if(getIsSendStopped())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QListIterator<FileData> serverIterator(fileSendList);
|
|
||||||
|
|
||||||
while(serverIterator.hasNext())
|
|
||||||
{
|
|
||||||
FileData data = serverIterator.next();
|
|
||||||
|
|
||||||
if (data.hash == "FOLDER")
|
|
||||||
{
|
|
||||||
sendFolderBlock(data.path);
|
|
||||||
socket->waitForBytesWritten();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sendFileBlock(data.path);
|
|
||||||
socket->waitForBytesWritten();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isSendStopped)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sendPacketType(PacketType::UPDATE_FILES_COMPLETE);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SendSystem::socketClose()
|
|
||||||
{
|
|
||||||
socket->close();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SendSystem::sendStop()
|
|
||||||
{
|
|
||||||
isSendStopped = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SendSystem::sendDocs(QString docsPath)
|
|
||||||
{
|
|
||||||
sendFileBlock(docsPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SendSystem::getIsSendStopped() const
|
|
||||||
{
|
|
||||||
return isSendStopped;
|
|
||||||
}
|
|
||||||
|
|
||||||
SendSystem::~SendSystem()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
slot_sendNotify(commandHashCompleteClient);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,55 +13,69 @@
|
|||||||
|
|
||||||
class DataParser;
|
class DataParser;
|
||||||
class FileData;
|
class FileData;
|
||||||
|
|
||||||
class SendSystem : public QObject
|
class SendSystem : public QObject
|
||||||
{
|
{
|
||||||
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit SendSystem(QObject* parent = nullptr);
|
explicit SendSystem(QObject* parent = nullptr);
|
||||||
|
~SendSystem();
|
||||||
|
|
||||||
void initialize(DataParser* dataParser,QMutex *globalMutex);
|
void initialize(DataParser* dataParser,QMutex *globalMutex);
|
||||||
void setClient(Client* client,QTcpSocket *socket);
|
void setClient(Client* client,QTcpSocket *socket);
|
||||||
void sendMessageBlock(QString message);
|
|
||||||
void sendFileBlock(QString path);
|
|
||||||
void sendFileBlockByteArray(QByteArray array, PacketType packetType);
|
|
||||||
void sendFileBlockWithRename(QString path,QString newName);
|
|
||||||
void sendFolderBlock(QString path);
|
|
||||||
void sendDeleteBlock(QString path);
|
|
||||||
void sendPacketType(PacketType packet);
|
|
||||||
void sendNotify(QString notify);
|
|
||||||
void sendStop();
|
|
||||||
void sendDocs(QString docPath);
|
|
||||||
void sendXmlAnswer(QByteArray array, PacketType packetType = PacketType::TYPE_XMLANSWER);
|
|
||||||
void sendNeedUpdate(bool flag,quint64 size,quint64 fileCount,quint64 deleteCount);
|
|
||||||
void updateFiles(QList<FileData> fileSendList, QList<FileData> deleteList);
|
void updateFiles(QList<FileData> fileSendList, QList<FileData> deleteList);
|
||||||
|
|
||||||
bool getIsSendStopped() const;
|
private:
|
||||||
|
bool waitWrittenData(QString marker, int msec = 500);
|
||||||
|
|
||||||
~SendSystem();
|
|
||||||
|
|
||||||
|
|
||||||
void updateFilesFULL(QList<FileData> fileSendList, QList<FileData> deleteList);
|
|
||||||
public slots:
|
public slots:
|
||||||
void socketClose();
|
void slot_BytesWrittenToSocket(qint64 bytes);
|
||||||
void sendVersion();
|
|
||||||
|
bool slot_getIsSendingStopped() const;
|
||||||
|
void slot_stopSending();
|
||||||
|
|
||||||
|
void slot_socketClose();
|
||||||
|
|
||||||
|
void slot_sendVersion();
|
||||||
|
|
||||||
|
void slot_sendNotify(QString notify);
|
||||||
|
void slot_sendPacketType(PacketType packet);
|
||||||
|
void slot_sendXmlAnswer(QByteArray array, PacketType packetType = PacketType::TYPE_XMLANSWER);
|
||||||
|
|
||||||
|
void slot_sendDocs_forQtClient(QString docPath);
|
||||||
|
|
||||||
|
void slot_sendNeedUpdate(bool flag,quint64 size,quint64 fileCount,quint64 deleteCount);
|
||||||
|
|
||||||
|
void slot_sendFolderBlock(QString path);
|
||||||
|
void slot_sendDeleteBlock(QString path);
|
||||||
|
|
||||||
|
void slot_sendFileBlock_forGUI(QString path);
|
||||||
|
void slot_sendFileBlock_forQtClient(QString path);
|
||||||
|
void slot_sendFileBlockByteArray(QByteArray array, PacketType packetType);
|
||||||
|
void slot_sendFileBlockWithRename_Hash_forQtClient(QString path,QString newName);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void sigLoadHash();
|
|
||||||
//QByteArray sigSendXMLmessage(QString loginFrom, QString loginTo, QString text, QString userType); //сигнал не используется
|
|
||||||
QByteArray sigSendNotify(QString message);
|
QByteArray sigSendNotify(QString message);
|
||||||
//QByteArray sigSendVersion(); //сигнал не используется
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Client *client;
|
Client *client;
|
||||||
QTcpSocket* socket;
|
QTcpSocket* socket;
|
||||||
DataParser* dataParser;
|
DataParser* dataParser;
|
||||||
quint64 fileSize;
|
|
||||||
QMutex *mutex;
|
QMutex *globalMutex; //Не используется (но пока оставлен)
|
||||||
QWaitCondition *waitCondition;
|
|
||||||
int countSend;
|
char* buffer;
|
||||||
bool isSendStopped;
|
|
||||||
TypeClientAutorization type;
|
TypeClientAutorization type;
|
||||||
|
|
||||||
|
bool flSendingStopped;
|
||||||
|
|
||||||
|
bool flWaitWritenToSocket;
|
||||||
|
qint64 bytesWritedToSocket;
|
||||||
|
|
||||||
|
qint64 fileSize;
|
||||||
|
int countSend;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SENDSYSTEM_H
|
#endif // SENDSYSTEM_H
|
||||||
|
|||||||
@@ -55,9 +55,11 @@ static const QString commandUnchangable = "UNCHANGEABLE";
|
|||||||
static const QString commandUpdateFilesClient = "update";
|
static const QString commandUpdateFilesClient = "update";
|
||||||
static const QString commandGetTasks = "GETTASKS";
|
static const QString commandGetTasks = "GETTASKS";
|
||||||
static const QString commandeGetOfflineMessages = "GETOFFLINEMESSAGE";
|
static const QString commandeGetOfflineMessages = "GETOFFLINEMESSAGE";
|
||||||
|
static const QString commandGetCFI = "GETCFI";
|
||||||
|
|
||||||
//static quint64 fileBlockSize = 1460;
|
//static quint64 fileBlockSize = 1460;
|
||||||
static quint64 sendFileBlockSize = 256000;
|
const int BLOCK_SIZE = 1024 * 1024; // Размер блока
|
||||||
|
static quint64 sendFileBlockSize = /*256000*/BLOCK_SIZE;
|
||||||
static quint64 readFileBlockSize = 65535;
|
static quint64 readFileBlockSize = 65535;
|
||||||
//1025*250
|
//1025*250
|
||||||
|
|
||||||
|
|||||||
@@ -54,10 +54,12 @@ void UpdateController::changeAssetVersion(QString versionName)
|
|||||||
|
|
||||||
currentStreamingPath = assetManager->setVersion(versionName);
|
currentStreamingPath = assetManager->setVersion(versionName);
|
||||||
setUpCurrentServerHash();
|
setUpCurrentServerHash();
|
||||||
emit sigUpdateDocsXML();
|
|
||||||
commonClientHandler->slot_sendPacketToAllClients(PacketType::HASH_READY, false);
|
commonClientHandler->slot_sendPacketToAllClients(PacketType::HASH_READY, false);
|
||||||
commonClientHandler->sendCurrentVersionToAllClient();
|
commonClientHandler->sendCurrentVersionToAllClient();
|
||||||
|
|
||||||
|
emit sigUpdateDocsXML();
|
||||||
|
|
||||||
//commonClientHandler->slot_sendPacketToAllClients(PacketType::FREE);
|
//commonClientHandler->slot_sendPacketToAllClients(PacketType::FREE);
|
||||||
res = emit signal_BlockAutorization(false, "SERVER", "ChangeAssetVersion");
|
res = emit signal_BlockAutorization(false, "SERVER", "ChangeAssetVersion");
|
||||||
}
|
}
|
||||||
@@ -91,7 +93,6 @@ void UpdateController::compareFiles(ClientHandler* handler, QByteArray array)
|
|||||||
mutex->unlock();
|
mutex->unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void UpdateController::showHash()
|
void UpdateController::showHash()
|
||||||
{
|
{
|
||||||
for(FileData& str : serverDataList){
|
for(FileData& str : serverDataList){
|
||||||
@@ -281,6 +282,7 @@ bool UpdateController::checkNeedUpdate(ClientHandler *handler)
|
|||||||
{
|
{
|
||||||
if(item.path.contains("Temp")) continue;
|
if(item.path.contains("Temp")) continue;
|
||||||
if(item.path.contains("docs.xml")) continue;
|
if(item.path.contains("docs.xml")) continue;
|
||||||
|
if(item.path.contains("CfiList.xml")) continue;
|
||||||
|
|
||||||
if (!serverDataList.contains(item))
|
if (!serverDataList.contains(item))
|
||||||
{
|
{
|
||||||
@@ -292,6 +294,7 @@ bool UpdateController::checkNeedUpdate(ClientHandler *handler)
|
|||||||
{
|
{
|
||||||
if(item.path.contains("Temp")) continue;
|
if(item.path.contains("Temp")) continue;
|
||||||
if(item.path.contains("docs.xml")) continue;
|
if(item.path.contains("docs.xml")) continue;
|
||||||
|
if(item.path.contains("CfiList.xml")) continue;
|
||||||
|
|
||||||
if (!clientDataList.contains(item))
|
if (!clientDataList.contains(item))
|
||||||
{
|
{
|
||||||
@@ -564,8 +567,6 @@ void UpdateController::xmlFileDataParse(QByteArray array)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
StreamingVersionData* UpdateController::getCurrentVersion()
|
StreamingVersionData* UpdateController::getCurrentVersion()
|
||||||
{
|
{
|
||||||
return assetManager->getCurrentVersionData();
|
return assetManager->getCurrentVersionData();
|
||||||
@@ -608,6 +609,7 @@ bool UpdateController::checkRequiredFolder()
|
|||||||
|
|
||||||
return required;
|
return required;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateController::~UpdateController()
|
UpdateController::~UpdateController()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -14,14 +14,15 @@ ClientHandler::ClientHandler( QObject *parent):
|
|||||||
void ClientHandler::initialize(int descriptor,
|
void ClientHandler::initialize(int descriptor,
|
||||||
UpdateController *updateController,DataParser *dataParser, QMutex *mutex)
|
UpdateController *updateController,DataParser *dataParser, QMutex *mutex)
|
||||||
{
|
{
|
||||||
this->socket = new QTcpSocket;
|
qDebug() << "ClientHandler::initialize thread ID " << QThread::currentThreadId();
|
||||||
this->thread = new QThread;
|
|
||||||
|
|
||||||
|
socket = new QTcpSocket;
|
||||||
|
thread = new QThread;
|
||||||
|
|
||||||
|
QIODevice::OpenMode openMode = socket->openMode();
|
||||||
socket->setParent(nullptr);
|
socket->setParent(nullptr);
|
||||||
socket->setSocketDescriptor(descriptor);
|
socket->setSocketDescriptor(descriptor);
|
||||||
|
|
||||||
qDebug() << "ClientHandler::initialize thread ID " << QThread::currentThreadId();
|
|
||||||
|
|
||||||
sendSystem = new SendSystem;
|
sendSystem = new SendSystem;
|
||||||
recognizeSystem = new RecognizeSystem;
|
recognizeSystem = new RecognizeSystem;
|
||||||
|
|
||||||
@@ -41,28 +42,29 @@ void ClientHandler::initialize(int descriptor,
|
|||||||
|
|
||||||
connect(recognizeSystem,&RecognizeSystem::signal_updateDocsXML,this,&ClientHandler::signal_updateDocsXML);
|
connect(recognizeSystem,&RecognizeSystem::signal_updateDocsXML,this,&ClientHandler::signal_updateDocsXML);
|
||||||
|
|
||||||
connect(this,&ClientHandler::sigSendXmlAnswer,sendSystem,&SendSystem::sendXmlAnswer,Qt::AutoConnection);
|
connect(this,&ClientHandler::sigSendXmlAnswer,sendSystem,&SendSystem::slot_sendXmlAnswer,Qt::AutoConnection);
|
||||||
connect(this,&ClientHandler::sigInitSender,sendSystem,&SendSystem::initialize,Qt::AutoConnection/*Qt::DirectConnection*/);
|
//connect(this,&ClientHandler::sigInitSender,sendSystem,&SendSystem::initialize,Qt::AutoConnection/*Qt::DirectConnection*/);
|
||||||
connect(this,&ClientHandler::sigFileBlock,sendSystem,&SendSystem::sendFileBlock,Qt::AutoConnection);
|
connect(this,&ClientHandler::sigFileBlock_forGUI,sendSystem,&SendSystem::slot_sendFileBlock_forGUI,Qt::AutoConnection);
|
||||||
connect(this,&ClientHandler::sigFileBlockByteArray,sendSystem,&SendSystem::sendFileBlockByteArray,Qt::AutoConnection);
|
connect(this,&ClientHandler::sigFileBlockByteArray,sendSystem,&SendSystem::slot_sendFileBlockByteArray,Qt::AutoConnection);
|
||||||
connect(this,&ClientHandler::sigFolderBlock,sendSystem,&SendSystem::sendFolderBlock,Qt::AutoConnection);
|
connect(this,&ClientHandler::sigFolderBlock,sendSystem,&SendSystem::slot_sendFolderBlock,Qt::AutoConnection);
|
||||||
connect(this,&ClientHandler::sigGetIsSendStopped,sendSystem,&SendSystem::getIsSendStopped,/*Qt::AutoConnection*/Qt::DirectConnection); //Возвращает значение
|
connect(this,&ClientHandler::sigGetIsSendStopped,sendSystem,&SendSystem::slot_getIsSendingStopped,/*Qt::AutoConnection*/Qt::DirectConnection); //Возвращает значение
|
||||||
connect(this,&ClientHandler::sigSendDeleteBlock,sendSystem,&SendSystem::sendDeleteBlock,Qt::AutoConnection);
|
connect(this,&ClientHandler::sigSendDeleteBlock,sendSystem,&SendSystem::slot_sendDeleteBlock,Qt::AutoConnection);
|
||||||
connect(this,&ClientHandler::sigNeedUpdate,sendSystem,&SendSystem::sendNeedUpdate,Qt::AutoConnection);
|
connect(this,&ClientHandler::sigNeedUpdate,sendSystem,&SendSystem::slot_sendNeedUpdate,Qt::AutoConnection);
|
||||||
connect(this,&ClientHandler::sigSendNotify,sendSystem,&SendSystem::sendNotify,Qt::AutoConnection);
|
connect(this,&ClientHandler::sigSendNotify,sendSystem,&SendSystem::slot_sendNotify,Qt::AutoConnection);
|
||||||
connect(this,&ClientHandler::sigSendFileBlockWithRename,sendSystem,&SendSystem::sendFileBlockWithRename,Qt::AutoConnection);
|
connect(this,&ClientHandler::sigSendFileBlockWithRename_Hash_forQtClient,sendSystem,&SendSystem::slot_sendFileBlockWithRename_Hash_forQtClient,Qt::AutoConnection);
|
||||||
connect(this,&ClientHandler::sigSendVersion,sendSystem,&SendSystem::sendVersion,Qt::AutoConnection);
|
connect(this,&ClientHandler::sigSendVersion,sendSystem,&SendSystem::slot_sendVersion,Qt::AutoConnection);
|
||||||
connect(this,&ClientHandler::sigSocketClose,sendSystem,&SendSystem::socketClose,Qt::AutoConnection);
|
connect(this,&ClientHandler::sigSocketClose,sendSystem,&SendSystem::slot_socketClose,Qt::AutoConnection);
|
||||||
//connect(this,&ClientHandler::sigSocketFlush,sendSystem,&SendSystem::socketFlush,Qt::AutoConnection); //не используется
|
//connect(this,&ClientHandler::sigSocketFlush,sendSystem,&SendSystem::socketFlush,Qt::AutoConnection); //не используется
|
||||||
connect(this,&ClientHandler::sigSendPacketType,sendSystem,&SendSystem::sendPacketType,Qt::AutoConnection);
|
connect(this,&ClientHandler::sigSendPacketType,sendSystem,&SendSystem::slot_sendPacketType,Qt::AutoConnection);
|
||||||
connect(this,&ClientHandler::sigSendStop,sendSystem,&SendSystem::sendStop,Qt::DirectConnection);
|
connect(this,&ClientHandler::sigSendStop,sendSystem,&SendSystem::slot_stopSending,Qt::DirectConnection);
|
||||||
|
|
||||||
connect(socket,&QTcpSocket::readyRead,this,&ClientHandler::initClientType,Qt::AutoConnection);
|
connect(socket,&QTcpSocket::readyRead,this,&ClientHandler::initClientType,Qt::AutoConnection);
|
||||||
initClientType();
|
initClientType();
|
||||||
|
|
||||||
recognizeSystem->initialize(updateController,dataParser,sendSystem, this);
|
recognizeSystem->initialize(updateController,dataParser, mutex,sendSystem, this);
|
||||||
sendSystem->setClient(client,socket);
|
sendSystem->setClient(client,socket);
|
||||||
emit sigInitSender(dataParser, mutex);
|
sendSystem->initialize(dataParser, mutex);
|
||||||
|
//emit sigInitSender(dataParser, mutex);
|
||||||
|
|
||||||
Logger::instance().log("SERVER: Client connected");
|
Logger::instance().log("SERVER: Client connected");
|
||||||
}
|
}
|
||||||
@@ -99,7 +101,7 @@ void ClientHandler::initClientType()
|
|||||||
void ClientHandler::sendHash()
|
void ClientHandler::sendHash()
|
||||||
{
|
{
|
||||||
QString path = "\\" + hashFileName;
|
QString path = "\\" + hashFileName;
|
||||||
emit sigSendFileBlockWithRename(path,"/serverHash.xml");
|
emit sigSendFileBlockWithRename_Hash_forQtClient(path,"/serverHash.xml");
|
||||||
//emit sigSendNotify("HASHSENDCOMPLETE");
|
//emit sigSendNotify("HASHSENDCOMPLETE");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,9 +135,9 @@ void ClientHandler::sendXmlAnswer(QByteArray array, PacketType packetType)
|
|||||||
emit sigSendXmlAnswer(array, packetType);
|
emit sigSendXmlAnswer(array, packetType);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientHandler::sendFileBlock(QString path)
|
void ClientHandler::sendFileBlock_forGUI(QString path)
|
||||||
{
|
{
|
||||||
emit sigFileBlock(path);
|
emit sigFileBlock_forGUI(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientHandler::sendFileBlockByteArray(QByteArray array, PacketType packetType)
|
void ClientHandler::sendFileBlockByteArray(QByteArray array, PacketType packetType)
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public:
|
|||||||
void initSender(DataParser *dataParser);
|
void initSender(DataParser *dataParser);
|
||||||
void sendXmlAnswer(QByteArray array, PacketType packetType = PacketType::TYPE_XMLANSWER);
|
void sendXmlAnswer(QByteArray array, PacketType packetType = PacketType::TYPE_XMLANSWER);
|
||||||
void sendFolderBlock(QString path);
|
void sendFolderBlock(QString path);
|
||||||
void sendFileBlock(QString path);
|
void sendFileBlock_forGUI(QString path);
|
||||||
void sendFileBlockByteArray(QByteArray array, PacketType packetType);
|
void sendFileBlockByteArray(QByteArray array, PacketType packetType);
|
||||||
bool getIsSendStopped();
|
bool getIsSendStopped();
|
||||||
void sendDeleteBlock(QString path);
|
void sendDeleteBlock(QString path);
|
||||||
@@ -51,9 +51,9 @@ public:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void sigSendXmlAnswer(QByteArray array, PacketType packetType);
|
void sigSendXmlAnswer(QByteArray array, PacketType packetType);
|
||||||
void sigInitSender (DataParser *dataParse, QMutex *mutex);
|
//void sigInitSender (DataParser *dataParse, QMutex *mutex);
|
||||||
void sigFolderBlock(QString path);
|
void sigFolderBlock(QString path);
|
||||||
void sigFileBlock(QString path);
|
void sigFileBlock_forGUI(QString path);
|
||||||
void sigFileBlockByteArray(QByteArray array, PacketType packetType);
|
void sigFileBlockByteArray(QByteArray array, PacketType packetType);
|
||||||
bool sigGetIsSendStopped();
|
bool sigGetIsSendStopped();
|
||||||
void sigSendDeleteBlock(QString path);
|
void sigSendDeleteBlock(QString path);
|
||||||
@@ -62,7 +62,7 @@ signals:
|
|||||||
void sigSendHash();
|
void sigSendHash();
|
||||||
void sigRecognize(ClientHandler *handler);
|
void sigRecognize(ClientHandler *handler);
|
||||||
void sigSendNotify(QString notify);
|
void sigSendNotify(QString notify);
|
||||||
void sigSendFileBlockWithRename (QString path,QString newName);
|
void sigSendFileBlockWithRename_Hash_forQtClient (QString path,QString newName);
|
||||||
void sigSocketClose();
|
void sigSocketClose();
|
||||||
//bool sigSocketFlush(); //не используется
|
//bool sigSocketFlush(); //не используется
|
||||||
void sigSendVersion();
|
void sigSendVersion();
|
||||||
@@ -71,6 +71,10 @@ signals:
|
|||||||
|
|
||||||
void signal_updateDocsXML();
|
void signal_updateDocsXML();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void initClientType();
|
||||||
|
void packetTypeInit(PacketType packet, Client *client);
|
||||||
|
|
||||||
public :
|
public :
|
||||||
QThread *thread;
|
QThread *thread;
|
||||||
QTcpSocket *socket;
|
QTcpSocket *socket;
|
||||||
@@ -82,11 +86,7 @@ private:
|
|||||||
UpdateController *updateController;
|
UpdateController *updateController;
|
||||||
RecognizeSystem *recognizeSystem;
|
RecognizeSystem *recognizeSystem;
|
||||||
Client *client;
|
Client *client;
|
||||||
|
|
||||||
SendSystem *sendSystem;
|
SendSystem *sendSystem;
|
||||||
|
|
||||||
void initClientType();
|
|
||||||
void packetTypeInit(PacketType packet, Client *client);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CLIENTHANDLER_H
|
#endif // CLIENTHANDLER_H
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ MultiThreadServer::MultiThreadServer(UpdateController *updateController, DocsUpd
|
|||||||
DataParser *dataParser,qint16 hostPort, QObject *parent ):
|
DataParser *dataParser,qint16 hostPort, QObject *parent ):
|
||||||
QTcpServer(parent),
|
QTcpServer(parent),
|
||||||
mutex(nullptr),
|
mutex(nullptr),
|
||||||
|
clientsMap(nullptr),
|
||||||
hostPort(hostPort),
|
hostPort(hostPort),
|
||||||
processingSystem(processingSystem),
|
processingSystem(processingSystem),
|
||||||
updateController(updateController),
|
updateController(updateController),
|
||||||
@@ -23,6 +24,7 @@ MultiThreadServer::MultiThreadServer(UpdateController *updateController, DocsUpd
|
|||||||
MultiThreadServer::~MultiThreadServer()
|
MultiThreadServer::~MultiThreadServer()
|
||||||
{
|
{
|
||||||
delete mutex;
|
delete mutex;
|
||||||
|
delete clientsMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiThreadServer::incomingConnection(qintptr socketDesriptor)
|
void MultiThreadServer::incomingConnection(qintptr socketDesriptor)
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public:
|
|||||||
{
|
{
|
||||||
return stateBlockAutorization;
|
return stateBlockAutorization;
|
||||||
}
|
}
|
||||||
EStateServer getStateServer()
|
EStateServer getStateServer() const
|
||||||
{
|
{
|
||||||
return stateServer;
|
return stateServer;
|
||||||
}
|
}
|
||||||
@@ -58,6 +58,9 @@ private:
|
|||||||
emit signal_StateServer(stateServer, stateBlockAutorization);
|
emit signal_StateServer(stateServer, stateBlockAutorization);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void removeClient(int idSocket);
|
||||||
|
void addClient(qintptr descriptor, ClientHandler *client);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
//void sigInitClient(int descriptor, ServerLMSWidget *serverWidget,
|
//void sigInitClient(int descriptor, ServerLMSWidget *serverWidget,
|
||||||
// UpdateController *updateController, DataParser *dataParser, QMutex *mutex);
|
// UpdateController *updateController, DataParser *dataParser, QMutex *mutex);
|
||||||
@@ -96,9 +99,6 @@ private:
|
|||||||
EStateServer stateServer;
|
EStateServer stateServer;
|
||||||
EStateBlockAutorization stateBlockAutorization;
|
EStateBlockAutorization stateBlockAutorization;
|
||||||
QMap<QString, QString> blockersMap;
|
QMap<QString, QString> blockersMap;
|
||||||
|
|
||||||
void removeClient(int idSocket);
|
|
||||||
void addClient(qintptr descriptor, ClientHandler *client);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MULTITHREADSERVER_H
|
#endif // MULTITHREADSERVER_H
|
||||||
|
|||||||
Reference in New Issue
Block a user