mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-27 19:45:43 +03:00
105 lines
2.7 KiB
C++
105 lines
2.7 KiB
C++
#ifndef MULTITHREADSERVER_H
|
|
#define MULTITHREADSERVER_H
|
|
|
|
#include "Systems/processingsystem.h"
|
|
#include "clienthandler.h"
|
|
#include "Data/PacketType.h"
|
|
#include "updatecontroller.h"
|
|
#include "Parsers/dataparser.h"
|
|
#include <QObject>
|
|
|
|
class ProcessingSystem;
|
|
class ClientHandler;
|
|
class DocsUpdater;
|
|
class DataParser;
|
|
class UpdateController;
|
|
|
|
class MultiThreadServer : public QTcpServer
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
MultiThreadServer(UpdateController *updateController, DocsUpdater *docsUpdater,ProcessingSystem *processingSystem,
|
|
DataParser *dataParser, qint16 hostPort, QObject *parent = nullptr);
|
|
~MultiThreadServer();
|
|
|
|
|
|
QMap<int, ClientHandler *> *getClientsMap() const;
|
|
QStringList getClientFullNameList();
|
|
void updateClientList();
|
|
void disableClients();
|
|
|
|
EStateBlockAutorization getStateBlockAutorization() const
|
|
{
|
|
return stateBlockAutorization;
|
|
}
|
|
EStateServer getStateServer() const
|
|
{
|
|
return stateServer;
|
|
}
|
|
QMutex *getMutex() const
|
|
{
|
|
return mutex;
|
|
}
|
|
|
|
private:
|
|
|
|
bool startServer();
|
|
bool stopServer();
|
|
|
|
void blockAutorization()
|
|
{
|
|
stateBlockAutorization = blocked;
|
|
emit signal_StateServer(stateServer, stateBlockAutorization);
|
|
}
|
|
void unBlockAutorization()
|
|
{
|
|
stateBlockAutorization = unblocked;
|
|
emit signal_StateServer(stateServer, stateBlockAutorization);
|
|
}
|
|
|
|
void removeClient(int idSocket);
|
|
void addClient(qintptr descriptor, ClientHandler *client);
|
|
|
|
signals:
|
|
//void sigInitClient(int descriptor, ServerLMSWidget *serverWidget,
|
|
// UpdateController *updateController, DataParser *dataParser, QMutex *mutex);
|
|
void signalStopSendFile();
|
|
|
|
void signal_BlockAutorizationIndicate(bool block, QString blocker, QString types);
|
|
void signal_sendPacketToAllClients(PacketType packetType, bool flOnlyGUI);
|
|
|
|
void signal_StateServer(EStateServer stateServer, EStateBlockAutorization stateBlockAutorization);
|
|
|
|
void signal_UpdateListClients(QStringList listFullName);
|
|
|
|
void signal_updateDocsXML();
|
|
|
|
public slots:
|
|
void slotDisconnectClient(QString peerAddress, QString peerPort);
|
|
|
|
bool slot_BlockAutorization(bool block, QString whoFullName, QString type);
|
|
|
|
void slot_StartServer();
|
|
void slot_StopServer();
|
|
|
|
void slot_UpdateDocs();
|
|
protected:
|
|
void incomingConnection(qintptr handle) override;
|
|
|
|
private:
|
|
QMutex *mutex;
|
|
QMap<int, ClientHandler*> *clientsMap;
|
|
qint16 hostPort;
|
|
ProcessingSystem *processingSystem;
|
|
UpdateController *updateController;
|
|
DocsUpdater *docsUpdater;
|
|
DataParser *dataParser;
|
|
|
|
EStateServer stateServer;
|
|
EStateBlockAutorization stateBlockAutorization;
|
|
QMap<QString, QString> blockersMap;
|
|
};
|
|
|
|
#endif // MULTITHREADSERVER_H
|