mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
naming changes to udt::Socket handlers
This commit is contained in:
parent
240f53ddd2
commit
7f53eda0d9
4 changed files with 15 additions and 15 deletions
|
@ -36,10 +36,10 @@ IceServer::IceServer(int argc, char* argv[]) :
|
||||||
|
|
||||||
// set processPacket as the verified packet callback for the udt::Socket
|
// set processPacket as the verified packet callback for the udt::Socket
|
||||||
using std::placeholders::_1;
|
using std::placeholders::_1;
|
||||||
_serverSocket.setVerifiedPacketCallback(std::bind(&IceServer::processPacket, this, _1));
|
_serverSocket.setVerifiedPacketHandler(std::bind(&IceServer::processPacket, this, _1));
|
||||||
|
|
||||||
// set packetVersionMatch as the verify packet operator for the udt::Socket
|
// set packetVersionMatch as the verify packet operator for the udt::Socket
|
||||||
_serverSocket.setVerifyPacketOperator(std::bind(&IceServer::packetVersionMatch, this, _1));
|
_serverSocket.setPacketVerificationHandler(std::bind(&IceServer::packetVersionMatch, this, _1));
|
||||||
|
|
||||||
// setup our timer to clear inactive peers
|
// setup our timer to clear inactive peers
|
||||||
QTimer* inactivePeerTimer = new QTimer(this);
|
QTimer* inactivePeerTimer = new QTimer(this);
|
||||||
|
|
|
@ -99,10 +99,10 @@ LimitedNodeList::LimitedNodeList(unsigned short socketListenPort, unsigned short
|
||||||
|
|
||||||
// set &PacketReceiver::handleVerifiedPacket as the verified packet callback for the udt::Socket
|
// set &PacketReceiver::handleVerifiedPacket as the verified packet callback for the udt::Socket
|
||||||
using std::placeholders::_1;
|
using std::placeholders::_1;
|
||||||
_nodeSocket.setVerifiedPacketCallback(std::bind(&PacketReceiver::handleVerifiedPacket, _packetReceiver, _1));
|
_nodeSocket.setVerifiedPacketHandler(std::bind(&PacketReceiver::handleVerifiedPacket, _packetReceiver, _1));
|
||||||
|
|
||||||
// set our isPacketVerified method as the verify operator for the udt::Socket
|
// set our isPacketVerified method as the verify operator for the udt::Socket
|
||||||
_nodeSocket.setVerifyPacketOperator(std::bind(&LimitedNodeList::isPacketVerified, this, _1));
|
_nodeSocket.setPacketVerificationHandler(std::bind(&LimitedNodeList::isPacketVerified, this, _1));
|
||||||
|
|
||||||
_packetStatTimer.start();
|
_packetStatTimer.start();
|
||||||
|
|
||||||
|
|
|
@ -89,10 +89,11 @@ void Socket::readPendingDatagrams() {
|
||||||
auto packet = Packet::fromReceivedPacket(std::move(buffer), packetSizeWithHeader, senderSockAddr);
|
auto packet = Packet::fromReceivedPacket(std::move(buffer), packetSizeWithHeader, senderSockAddr);
|
||||||
|
|
||||||
// call our verification operator to see if this packet is verified
|
// call our verification operator to see if this packet is verified
|
||||||
if (_unfilteredSockAddrs.contains(senderSockAddr) || !_verifyPacketOperator || _verifyPacketOperator(*packet)) {
|
if (_unfilteredSockAddrs.contains(senderSockAddr) || !_packetVerificationHandler || _packetVerificationHandler(*packet)) {
|
||||||
|
if (_verifiedPacketHandler) {
|
||||||
// call the verified packet callback to let it handle this packet
|
// call the verified packet callback to let it handle this packet
|
||||||
return _verifiedPacketCallback(std::move(packet));
|
return _verifiedPacketHandler(std::move(packet));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,8 +24,8 @@
|
||||||
|
|
||||||
namespace udt {
|
namespace udt {
|
||||||
|
|
||||||
using VerifyPacketOperator = std::function<bool(const Packet&)>;
|
using PacketVerificationHandler = std::function<bool(const Packet&)>;
|
||||||
using VerifiedPacketCallback = std::function<void(std::unique_ptr<Packet>)>;
|
using VerifiedPacketHandler = std::function<void(std::unique_ptr<Packet>)>;
|
||||||
|
|
||||||
class Socket : public QObject {
|
class Socket : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -43,9 +43,8 @@ public:
|
||||||
void bind(const QHostAddress& address, quint16 port = 0) { _udpSocket.bind(address, port); }
|
void bind(const QHostAddress& address, quint16 port = 0) { _udpSocket.bind(address, port); }
|
||||||
void rebind();
|
void rebind();
|
||||||
|
|
||||||
void setVerifyPacketOperator(VerifyPacketOperator verifyPacketOperator) { _verifyPacketOperator = verifyPacketOperator; }
|
void setPacketVerificationHandler(PacketVerificationHandler handler) { _packetVerificationHandler = handler; }
|
||||||
void setVerifiedPacketCallback(VerifiedPacketCallback verifiedPacketCallback)
|
void setVerifiedPacketHandler(VerifiedPacketHandler handler) { _verifiedPacketHandler = handler; }
|
||||||
{ _verifiedPacketCallback = verifiedPacketCallback; }
|
|
||||||
|
|
||||||
void setBufferSizes(int numBytes);
|
void setBufferSizes(int numBytes);
|
||||||
|
|
||||||
|
@ -56,8 +55,8 @@ private slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QUdpSocket _udpSocket { this };
|
QUdpSocket _udpSocket { this };
|
||||||
VerifyPacketOperator _verifyPacketOperator;
|
PacketVerificationHandler _packetVerificationHandler;
|
||||||
VerifiedPacketCallback _verifiedPacketCallback;
|
VerifiedPacketHandler _verifiedPacketHandler;
|
||||||
|
|
||||||
QSet<HifiSockAddr> _unfilteredSockAddrs;
|
QSet<HifiSockAddr> _unfilteredSockAddrs;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue