mirror of
https://github.com/jie65535/DaemonService.git
synced 2024-07-27 19:04:56 +08:00
46 lines
926 B
C++
46 lines
926 B
C++
#ifndef DAEMONSERVICE_H
|
|
#define DAEMONSERVICE_H
|
|
|
|
#include <QObject>
|
|
#include <QtNetwork>
|
|
#include <QList>
|
|
#include <QDateTime>
|
|
#include <QString>
|
|
|
|
/**
|
|
* @brief 守护服务类,单例实现
|
|
*/
|
|
class DaemonService : public QTcpServer
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
/**
|
|
* @brief 单例对象
|
|
* @return 唯一对象
|
|
*/
|
|
static DaemonService& instance()
|
|
{
|
|
static DaemonService obj;
|
|
return obj;
|
|
}
|
|
|
|
void setPortList(QList<int> portList)
|
|
{
|
|
this->m_portList = portList;
|
|
}
|
|
|
|
private:
|
|
explicit DaemonService() = default;
|
|
DaemonService(const DaemonService&) = delete;
|
|
DaemonService& operator=(const DaemonService&) = delete;
|
|
protected:
|
|
/**
|
|
* @brief 当有新连接进入时
|
|
*/
|
|
virtual void incomingConnection(qintptr socketDescriptor);
|
|
private:
|
|
QList<int> m_portList;
|
|
};
|
|
|
|
#endif // DAEMONSERVICE_H
|