mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 11:57:58 +02:00
Code cleanup
This commit is contained in:
parent
c05105e2f9
commit
fd1648c0d7
4 changed files with 20 additions and 22 deletions
|
@ -275,7 +275,7 @@ qint64 LimitedNodeList::sendPacket(std::unique_ptr<NLPacket> packet, const Node&
|
|||
}
|
||||
|
||||
qint64 LimitedNodeList::sendPacket(std::unique_ptr<NLPacket> packet, const HifiSockAddr& sockAddr) {
|
||||
return writeDatagram(packet->getData(), sockAddr);
|
||||
return writeDatagram({packet->getData(), static_cast<int>(packet->getSizeWithHeader())}, sockAddr);
|
||||
}
|
||||
|
||||
qint64 LimitedNodeList::sendPacketList(NLPacketList& packetList, const Node& destinationNode) {
|
||||
|
|
|
@ -42,8 +42,6 @@
|
|||
#include "NLPacketList.h"
|
||||
#include "UUIDHasher.h"
|
||||
|
||||
const int MAX_PACKET_SIZE = 1450;
|
||||
|
||||
const quint64 NODE_SILENCE_THRESHOLD_MSECS = 2 * 1000;
|
||||
|
||||
extern const char SOLO_NODE_TYPES[2];
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
|
||||
#include "Packet.h"
|
||||
|
||||
#include "../LimitedNodeList.h"
|
||||
|
||||
qint64 Packet::localHeaderSize(PacketType::Value type) {
|
||||
qint64 size = numBytesForArithmeticCodedPacketType(type) + sizeof(PacketVersion) +
|
||||
((SEQUENCE_NUMBERED_PACKETS.contains(type)) ? sizeof(SequenceNumber) : 0);
|
||||
|
@ -44,23 +42,24 @@ Packet::Packet(PacketType::Value type, qint64 size) :
|
|||
_packetSize(localHeaderSize(_type) + size),
|
||||
_packet(new char(_packetSize)),
|
||||
_payloadStart(_packet.get() + localHeaderSize(_type)),
|
||||
_capacity(size) {
|
||||
auto maxPayload = maxPayloadSize(type);
|
||||
if (size == -1) {
|
||||
// default size of -1, means biggest packet possible
|
||||
size = maxPayload;
|
||||
}
|
||||
|
||||
// Sanity check
|
||||
Q_ASSERT(size >= 0 || size < maxPayload);
|
||||
|
||||
// copy packet type and version in header
|
||||
writePacketTypeAndVersion(type);
|
||||
|
||||
// Set control bit and sequence number to 0 if necessary
|
||||
if (SEQUENCE_NUMBERED_PACKETS.contains(type)) {
|
||||
writeSequenceNumber(0);
|
||||
}
|
||||
_capacity(size)
|
||||
{
|
||||
auto maxPayload = maxPayloadSize(type);
|
||||
if (size == -1) {
|
||||
// default size of -1, means biggest packet possible
|
||||
size = maxPayload;
|
||||
}
|
||||
|
||||
// Sanity check
|
||||
Q_ASSERT(size >= 0 || size < maxPayload);
|
||||
|
||||
// copy packet type and version in header
|
||||
writePacketTypeAndVersion(type);
|
||||
|
||||
// Set control bit and sequence number to 0 if necessary
|
||||
if (SEQUENCE_NUMBERED_PACKETS.contains(type)) {
|
||||
writeSequenceNumber(0);
|
||||
}
|
||||
}
|
||||
|
||||
Packet::Packet(const Packet& other) {
|
||||
|
|
|
@ -83,6 +83,7 @@ namespace PacketType {
|
|||
ICEPingReply
|
||||
};
|
||||
};
|
||||
const int MAX_PACKET_SIZE = 1450;
|
||||
|
||||
typedef char PacketVersion;
|
||||
|
||||
|
|
Loading…
Reference in a new issue