mirror of
https://github.com/overte-org/overte.git
synced 2025-04-29 21:22:46 +02:00
Make sendUnreliable take a non const
This commit is contained in:
parent
121b9738a1
commit
ffdd54d41f
4 changed files with 10 additions and 8 deletions
|
@ -262,7 +262,7 @@ void LimitedNodeList::fillPacketHeader(const NLPacket& packet, const QUuid& conn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 LimitedNodeList::sendUnreliablePacket(const NLPacket& packet, const Node& destinationNode) {
|
qint64 LimitedNodeList::sendUnreliablePacket(NLPacket& packet, const Node& destinationNode) {
|
||||||
if (!destinationNode.getActiveSocket()) {
|
if (!destinationNode.getActiveSocket()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -270,7 +270,7 @@ qint64 LimitedNodeList::sendUnreliablePacket(const NLPacket& packet, const Node&
|
||||||
return sendUnreliablePacket(packet, *destinationNode.getActiveSocket(), destinationNode.getConnectionSecret());
|
return sendUnreliablePacket(packet, *destinationNode.getActiveSocket(), destinationNode.getConnectionSecret());
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 LimitedNodeList::sendUnreliablePacket(const NLPacket& packet, const HifiSockAddr& sockAddr,
|
qint64 LimitedNodeList::sendUnreliablePacket(NLPacket& packet, const HifiSockAddr& sockAddr,
|
||||||
const QUuid& connectionSecret) {
|
const QUuid& connectionSecret) {
|
||||||
Q_ASSERT_X(!packet.isReliable(), "LimitedNodeList::sendUnreliablePacket",
|
Q_ASSERT_X(!packet.isReliable(), "LimitedNodeList::sendUnreliablePacket",
|
||||||
"Trying to send a reliable packet unreliably.");
|
"Trying to send a reliable packet unreliably.");
|
||||||
|
@ -516,7 +516,7 @@ unsigned int LimitedNodeList::broadcastToNodes(std::unique_ptr<NLPacket> packet,
|
||||||
|
|
||||||
eachNode([&](const SharedNodePointer& node){
|
eachNode([&](const SharedNodePointer& node){
|
||||||
if (node && destinationNodeTypes.contains(node->getType())) {
|
if (node && destinationNodeTypes.contains(node->getType())) {
|
||||||
writePacket(*packet, *node);
|
sendUnreliablePacket(*packet, *node);
|
||||||
++n;
|
++n;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -116,8 +116,8 @@ public:
|
||||||
|
|
||||||
PacketReceiver& getPacketReceiver() { return *_packetReceiver; }
|
PacketReceiver& getPacketReceiver() { return *_packetReceiver; }
|
||||||
|
|
||||||
qint64 sendUnreliablePacket(const NLPacket& packet, const Node& destinationNode);
|
qint64 sendUnreliablePacket(NLPacket& packet, const Node& destinationNode);
|
||||||
qint64 sendUnreliablePacket(const NLPacket& packet, const HifiSockAddr& sockAddr,
|
qint64 sendUnreliablePacket(NLPacket& packet, const HifiSockAddr& sockAddr,
|
||||||
const QUuid& connectionSecret = QUuid());
|
const QUuid& connectionSecret = QUuid());
|
||||||
|
|
||||||
qint64 sendPacket(std::unique_ptr<NLPacket> packet, const Node& destinationNode);
|
qint64 sendPacket(std::unique_ptr<NLPacket> packet, const Node& destinationNode);
|
||||||
|
|
|
@ -67,11 +67,11 @@ void Socket::setBufferSizes(int numBytes) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 Socket::writePacket(const Packet& packet, const HifiSockAddr& sockAddr) {
|
qint64 Socket::writePacket(Packet& packet, const HifiSockAddr& sockAddr) {
|
||||||
Q_ASSERT_X(!packet.isReliable(), "Socket::writePacket", "Cannot send a reliable packet unreliably");
|
Q_ASSERT_X(!packet.isReliable(), "Socket::writePacket", "Cannot send a reliable packet unreliably");
|
||||||
|
|
||||||
// TODO: write the correct sequence number to the Packet here
|
// TODO: write the correct sequence number to the Packet here
|
||||||
// const_cast<NLPacket&>(packet).writeSequenceNumber(sequenceNumber);
|
packet.setSequenceNumber(_currentUnreliableSequenceNumber);
|
||||||
|
|
||||||
return writeDatagram(packet.getData(), packet.getDataSize(), sockAddr);
|
return writeDatagram(packet.getData(), packet.getDataSize(), sockAddr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ public:
|
||||||
quint16 localPort() const { return _udpSocket.localPort(); }
|
quint16 localPort() const { return _udpSocket.localPort(); }
|
||||||
|
|
||||||
// Simple functions writing to the socket with no processing
|
// Simple functions writing to the socket with no processing
|
||||||
qint64 writePacket(const Packet& packet, const HifiSockAddr& sockAddr);
|
qint64 writePacket(Packet& packet, const HifiSockAddr& sockAddr);
|
||||||
qint64 writePacket(std::unique_ptr<Packet> packet, const HifiSockAddr& sockAddr);
|
qint64 writePacket(std::unique_ptr<Packet> packet, const HifiSockAddr& sockAddr);
|
||||||
qint64 writeDatagram(const char* data, qint64 size, const HifiSockAddr& sockAddr);
|
qint64 writeDatagram(const char* data, qint64 size, const HifiSockAddr& sockAddr);
|
||||||
qint64 writeDatagram(const QByteArray& datagram, const HifiSockAddr& sockAddr);
|
qint64 writeDatagram(const QByteArray& datagram, const HifiSockAddr& sockAddr);
|
||||||
|
@ -69,6 +69,8 @@ private:
|
||||||
PacketFilterOperator _packetFilterOperator;
|
PacketFilterOperator _packetFilterOperator;
|
||||||
PacketHandler _packetHandler;
|
PacketHandler _packetHandler;
|
||||||
|
|
||||||
|
SequenceNumber _currentUnreliableSequenceNumber;
|
||||||
|
|
||||||
std::unordered_map<HifiSockAddr, BasePacketHandler> _unfilteredHandlers;
|
std::unordered_map<HifiSockAddr, BasePacketHandler> _unfilteredHandlers;
|
||||||
|
|
||||||
std::unordered_map<HifiSockAddr, SequenceNumber> _packetSequenceNumbers;
|
std::unordered_map<HifiSockAddr, SequenceNumber> _packetSequenceNumbers;
|
||||||
|
|
Loading…
Reference in a new issue