QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
UdpPeer.h
Go to the documentation of this file.
1#pragma once
2
3#include <QtCore/QString>
4#include <QtNetwork/QHostAddress>
5
6inline QString udpPeerKey(const QHostAddress& address, quint16 port)
7{
8 return address.toString() + QLatin1Char(':') + QString::number(port);
9}
10
12{
13 static constexpr qsizetype MAX_DATAGRAMS = 16;
14 static constexpr qsizetype MAX_BYTES = 64 * 1024;
15 qsizetype datagrams = 0;
16 qsizetype bytes = 0;
17
18 bool available() const { return datagrams < MAX_DATAGRAMS && bytes < MAX_BYTES; }
19
20 void consume(qsizetype size)
21 {
22 ++datagrams;
23 bytes += size;
24 }
25};
QString udpPeerKey(const QHostAddress &address, quint16 port)
Definition UdpPeer.h:6
static constexpr qsizetype MAX_DATAGRAMS
Definition UdpPeer.h:13
void consume(qsizetype size)
Definition UdpPeer.h:20
static constexpr qsizetype MAX_BYTES
Definition UdpPeer.h:14
qsizetype datagrams
Definition UdpPeer.h:15
qsizetype bytes
Definition UdpPeer.h:16
bool available() const
Definition UdpPeer.h:18