culturered_client/TouchScreen/MainServer.h

31 lines
582 B
C
Raw Normal View History

2024-09-07 03:34:44 +00:00
#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;
};