31 lines
582 B
C++
31 lines
582 B
C++
#pragma once
|
|
|
|
#include <QTcpServer>
|
|
#include <QUdpSocket>
|
|
#include <QTimer>
|
|
|
|
class QMainServer : public QTcpServer {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit QMainServer(QObject* param = nullptr);
|
|
~QMainServer() override = default;
|
|
|
|
bool Start(quint16 port);
|
|
void Stop();
|
|
|
|
void writeIndex(qint32 index);
|
|
void BroadcastCmd(const QString& cmd);
|
|
|
|
protected:
|
|
void OnNewConnection();
|
|
void OnDisConnected();
|
|
void OnStateChanged(QAbstractSocket::SocketState socketState);
|
|
void OnReadyRead();
|
|
|
|
private:
|
|
QVector<QTcpSocket*> m_tcpSockets;
|
|
|
|
QUdpSocket m_udpSocket;
|
|
QTimer m_boardcastTimer;
|
|
}; |