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

45 lines
1.2 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef CEDIANUDPPROTOCOL_H
#define CEDIANUDPPROTOCOL_H
#include <qqtprotocol.h>
#include <cedianudpmessage.h>
#include <qqtcore.h>
#include <cedianudpserver.h>
class CedianUdpProtocol : public QQtProtocol
{
Q_OBJECT
public:
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:
virtual bool dispatcher ( const QByteArray& ) override;
private:
/*发送者IP 端口 这个IP比较重要但是在程序中没有用*/
QHostAddress mAddress;
qint32 mPort;
/*这个端口是重点*/
qint32 mLocalPort;
CedianUdpMessage mMsg;
QNetworkDatagram mDG;
};
/*建议空调用一次赋值parent进行初始化*/
CedianUdpProtocol* cedianUdpServer ( QObject* parent = 0 );
qint32 cedianUdpPort ( int siteID, qint32* portList = 0 );
#endif // CEDIANUDPPROTOCOL_H