mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-27 19:45:43 +03:00
ref: delete duplicate meth
This commit is contained in:
@@ -1,36 +0,0 @@
|
|||||||
```
|
|
||||||
void SendSystem::sendMessageBlock(QString message)
|
|
||||||
{
|
|
||||||
QDataStream stream(socket);
|
|
||||||
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
|
||||||
QByteArray result = sendMessage(message);
|
|
||||||
stream << PacketType::TYPE_XMLANSWER;
|
|
||||||
stream << sendMessage(message);
|
|
||||||
socket->waitForBytesWritten();
|
|
||||||
socket->flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
или файлом
|
|
||||||
|
|
||||||
void ServerLMSWidget::sendQDataStream(QTcpSocket *socket,QByteArray data)
|
|
||||||
{
|
|
||||||
QDataStream stream(socket);
|
|
||||||
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
|
||||||
stream << PacketType::TYPE_XMLANSWER;
|
|
||||||
stream << data;
|
|
||||||
socket->waitForBytesWritten();
|
|
||||||
socket->flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
Типы сообщений QT->Unity:
|
|
||||||
TYPE_XMLANSWER
|
|
||||||
Остальные QT->QT
|
|
||||||
|
|
||||||
Сообщение порядок приема данных QDataStream:
|
|
||||||
1. размер сообщения(отсылается неявно)
|
|
||||||
2. само сообщение в бинарном формате(в нашем случае XML)
|
|
||||||
|
|
||||||
UNITY: при переходе на новую систему общения пакетами нужно:
|
|
||||||
отправлять пакет о типе XML ответа при каждой отправке
|
|
||||||
67
DOCS/Отправка.md
Normal file
67
DOCS/Отправка.md
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
Отправка сообщений QT сервер:
|
||||||
|
Отправка маленьких XML пакетов без информации о размере. TYPE_XMLANSWER
|
||||||
|
|
||||||
|
```
|
||||||
|
void SendSystem::sendXmlAnswer(QByteArray array, PacketType packetType)
|
||||||
|
{
|
||||||
|
qDebug() << "SendSystemThread: " << QThread::currentThreadId();
|
||||||
|
Logger::instance().log("C: " + client->getLogin() + " send pack " + enumToString(packetType) +
|
||||||
|
" " + QString::fromUtf8(array),LogLevel::DEBUG);
|
||||||
|
if (client->getClientType() == TypeClientAutorization::TYPE_QT_CLIENT ||
|
||||||
|
client->getClientType() == TypeClientAutorization::TYPE_GUI)
|
||||||
|
|
||||||
|
{
|
||||||
|
// для QT
|
||||||
|
QDataStream stream(socket);
|
||||||
|
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
||||||
|
stream << packetType;
|
||||||
|
stream << array;
|
||||||
|
socket->waitForBytesWritten();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // для Unity
|
||||||
|
sendPacketType(packetType);
|
||||||
|
QByteArray message;
|
||||||
|
int size = array.length();
|
||||||
|
message.append(reinterpret_cast<char*>(&size), sizeof(int));
|
||||||
|
socket->write(message);
|
||||||
|
socket->write(array);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Отправка пакета без вложения:
|
||||||
|
`void SendSystem::sendPacketType(PacketType packetType)
|
||||||
|
{
|
||||||
|
if (client->getClientType() == TypeClientAutorization::TYPE_QT_CLIENT ||
|
||||||
|
client->getClientType() == TypeClientAutorization::TYPE_GUI)
|
||||||
|
{
|
||||||
|
//Для QT
|
||||||
|
QDataStream stream(socket);
|
||||||
|
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
||||||
|
stream << packetType;
|
||||||
|
socket->waitForReadyRead(100);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//для Unity
|
||||||
|
QByteArray message;
|
||||||
|
int type = (int)packetType;
|
||||||
|
message.append(reinterpret_cast<char*>(&type), sizeof(int));
|
||||||
|
socket->write(message);
|
||||||
|
}
|
||||||
|
}`
|
||||||
|
|
||||||
|
Не подходит для последнего сообщения (например при отключении клиента)
|
||||||
|
Типы сообщений QT->Unity:
|
||||||
|
TYPE_XMLANSWER
|
||||||
|
Остальные QT->QT
|
||||||
|
|
||||||
|
Сообщение порядок приема данных QDataStream:
|
||||||
|
1. размер сообщения(отсылается неявно)
|
||||||
|
2. само сообщение в бинарном формате(в нашем случае XML)
|
||||||
|
|
||||||
|
UNITY: при переходе на новую систему общения пакетами нужно:
|
||||||
|
отправлять пакет о типе XML ответа при каждой отправке
|
||||||
|
|
||||||
@@ -24,10 +24,11 @@ void SendSystem::setClient(Client *client,QTcpSocket *socket)
|
|||||||
isSendStopped = false;
|
isSendStopped = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendSystem::sendMessageBlock(QString message)
|
void SendSystem::sendNotify(QString notify)
|
||||||
{
|
{
|
||||||
auto messageBlock = emit sigSendNotify(message);
|
qDebug() << "SendNotify thread: " << QThread::currentThreadId();
|
||||||
sendXmlAnswer(messageBlock);
|
auto answer = emit sigSendNotify(notify);
|
||||||
|
sendXmlAnswer(answer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendSystem::sendFileBlock(QString path)
|
void SendSystem::sendFileBlock(QString path)
|
||||||
@@ -234,13 +235,6 @@ void SendSystem::sendHello()
|
|||||||
socket->write(SERVER_HELLO);
|
socket->write(SERVER_HELLO);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendSystem::sendNotify(QString notify)
|
|
||||||
{
|
|
||||||
qDebug() << "SendNotify thread: " << QThread::currentThreadId();
|
|
||||||
auto answer = emit sigSendNotify(notify);//"END");
|
|
||||||
sendXmlAnswer(answer);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SendSystem::sendXmlAnswer(QByteArray array, PacketType packetType)
|
void SendSystem::sendXmlAnswer(QByteArray array, PacketType packetType)
|
||||||
{
|
{
|
||||||
qDebug() << "SendSystemThread: " << QThread::currentThreadId();
|
qDebug() << "SendSystemThread: " << QThread::currentThreadId();
|
||||||
|
|||||||
@@ -360,7 +360,7 @@ QList<FileData>* UpdateController::calculateHash(QString path)
|
|||||||
QFile file(fileInfo.absoluteFilePath());
|
QFile file(fileInfo.absoluteFilePath());
|
||||||
|
|
||||||
quint64 fileSize = file.size(); //буффер для хэширования крупных файлов
|
quint64 fileSize = file.size(); //буффер для хэширования крупных файлов
|
||||||
const quint64 bufferSize = 10240;
|
const quint64 bufferSize = 1024;
|
||||||
|
|
||||||
if(fileInfo.isHidden()) continue;
|
if(fileInfo.isHidden()) continue;
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ void ClientHandler::initialize(int descriptor,ServerLMSWidget *serverWidget,
|
|||||||
connect(this,&ClientHandler::sigFolderBlock,sendSystem,&SendSystem::sendFolderBlock,Qt::AutoConnection);
|
connect(this,&ClientHandler::sigFolderBlock,sendSystem,&SendSystem::sendFolderBlock,Qt::AutoConnection);
|
||||||
connect(this,&ClientHandler::sigGetIsSendStopped,sendSystem,&SendSystem::getIsSendStopped,Qt::AutoConnection);
|
connect(this,&ClientHandler::sigGetIsSendStopped,sendSystem,&SendSystem::getIsSendStopped,Qt::AutoConnection);
|
||||||
connect(this,&ClientHandler::sigSendDeleteBlock,sendSystem,&SendSystem::sendDeleteBlock,Qt::AutoConnection);
|
connect(this,&ClientHandler::sigSendDeleteBlock,sendSystem,&SendSystem::sendDeleteBlock,Qt::AutoConnection);
|
||||||
connect(this,&ClientHandler::sigSendMessageBlock,sendSystem,&SendSystem::sendMessageBlock,Qt::AutoConnection);
|
|
||||||
connect(this,&ClientHandler::sigNeedUpdate,sendSystem,&SendSystem::sendNeedUpdate,Qt::AutoConnection);
|
connect(this,&ClientHandler::sigNeedUpdate,sendSystem,&SendSystem::sendNeedUpdate,Qt::AutoConnection);
|
||||||
connect(this,&ClientHandler::sigSendNotify,sendSystem,&SendSystem::sendNotify,Qt::AutoConnection);
|
connect(this,&ClientHandler::sigSendNotify,sendSystem,&SendSystem::sendNotify,Qt::AutoConnection);
|
||||||
connect(this,&ClientHandler::sigSendFileBlockWithRename,sendSystem,&SendSystem::sendFileBlockWithRename,Qt::AutoConnection);
|
connect(this,&ClientHandler::sigSendFileBlockWithRename,sendSystem,&SendSystem::sendFileBlockWithRename,Qt::AutoConnection);
|
||||||
@@ -151,9 +150,9 @@ void ClientHandler::sendDeleteBlock(QString path)
|
|||||||
emit sigSendDeleteBlock(path);
|
emit sigSendDeleteBlock(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientHandler::sendMessageBlock(QString text)
|
void ClientHandler::sendNotify(QString text)
|
||||||
{
|
{
|
||||||
emit sigSendMessageBlock(text);
|
emit sigSendNotify(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientHandler::sendNeedUpdate(bool flag, quint64 size, quint64 fileCount,quint64 deleteCount)
|
void ClientHandler::sendNeedUpdate(bool flag, quint64 size, quint64 fileCount,quint64 deleteCount)
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public:
|
|||||||
bool getIsSendStopped();
|
bool getIsSendStopped();
|
||||||
void sendDeleteBlock(QString path);
|
void sendDeleteBlock(QString path);
|
||||||
void sendFinish();
|
void sendFinish();
|
||||||
void sendMessageBlock(QString text);
|
void sendNotify(QString text);
|
||||||
void sendNeedUpdate(bool flag, quint64 size,quint64 fileCount,quint64 deleteCount);
|
void sendNeedUpdate(bool flag, quint64 size,quint64 fileCount,quint64 deleteCount);
|
||||||
void sendDisable();
|
void sendDisable();
|
||||||
void recognize();
|
void recognize();
|
||||||
@@ -57,7 +57,6 @@ signals:
|
|||||||
void sigFileBlockByteArray(QByteArray array, PacketType packetType);
|
void sigFileBlockByteArray(QByteArray array, PacketType packetType);
|
||||||
bool sigGetIsSendStopped();
|
bool sigGetIsSendStopped();
|
||||||
void sigSendDeleteBlock(QString path);
|
void sigSendDeleteBlock(QString path);
|
||||||
void sigSendMessageBlock(QString text);
|
|
||||||
void sigNeedUpdate(bool flag,quint64 size,quint64 fileCount,quint64 deleteCount);
|
void sigNeedUpdate(bool flag,quint64 size,quint64 fileCount,quint64 deleteCount);
|
||||||
void sigClientDisconnected(QString address,QString port);
|
void sigClientDisconnected(QString address,QString port);
|
||||||
void sigSendHash();
|
void sigSendHash();
|
||||||
|
|||||||
Reference in New Issue
Block a user