1
0
mirror of https://gitee.com/drabel/LibQQt.git synced 2025-01-04 10:18:44 +08:00
LibQQt/examples/qqtudpexample/cedianudpprotocol.h

45 lines
1.2 KiB
C
Raw Normal View History

2018-05-26 14:49:18 +08:00
#ifndef CEDIANUDPPROTOCOL_H
#define CEDIANUDPPROTOCOL_H
2018-05-26 14:49:18 +08:00
#include <qqtprotocol.h>
#include <cedianudpmessage.h>
#include <qqtcore.h>
#include <cedianudpserver.h>
2018-05-26 14:49:18 +08:00
class CedianUdpProtocol : public QQtProtocol
{
Q_OBJECT
public:
2018-05-26 14:49:18 +08:00
explicit CedianUdpProtocol ( QObject* parent = nullptr );
virtual ~CedianUdpProtocol() {}
QNetworkDatagram& dataGram() { return mDG; }
QHostAddress& address() { return mAddress; }
qint32& port() { return mPort; }
qint32& localPort() { return mLocalPort; }
CedianUdpMessage& msg() { return mMsg; }
signals:
void msgIncoming();
public slots:
// QQtUdpProtocol interface
protected:
2018-05-26 14:49:18 +08:00
virtual bool dispatcher ( const QByteArray& ) override;
private:
/*发送者IP 端口 这个IP比较重要但是在程序中没有用*/
QHostAddress mAddress;
qint32 mPort;
/*这个端口是重点*/
qint32 mLocalPort;
CedianUdpMessage mMsg;
QNetworkDatagram mDG;
};
/*建议空调用一次赋值parent进行初始化*/
2018-05-26 14:49:18 +08:00
CedianUdpProtocol* cedianUdpServer ( QObject* parent = 0 );
qint32 cedianUdpPort ( int siteID, qint32* portList = 0 );
#endif // CEDIANUDPPROTOCOL_H