mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 04:03:35 +02:00
fix variable setup in Packet constructor
This commit is contained in:
parent
88f419dfd7
commit
a5ca1f7125
3 changed files with 13 additions and 8 deletions
|
@ -288,7 +288,6 @@ void DomainServer::setupNodeListAndAssignments(const QUuid& sessionUUID) {
|
||||||
packetReceiver.registerListener(PacketType::NodeJsonStats, this, "processNodeJSONStatsPacket");
|
packetReceiver.registerListener(PacketType::NodeJsonStats, this, "processNodeJSONStatsPacket");
|
||||||
packetReceiver.registerListener(PacketType::ICEPing, this, "processICEPingPacket");
|
packetReceiver.registerListener(PacketType::ICEPing, this, "processICEPingPacket");
|
||||||
packetReceiver.registerListener(PacketType::ICEPingReply, this, "processICEPingReplyPacket");
|
packetReceiver.registerListener(PacketType::ICEPingReply, this, "processICEPingReplyPacket");
|
||||||
packetReceiver.registerListener(PacketType::ICEServerPeerInformation, this, "processICEPeerInformationPacket");
|
|
||||||
|
|
||||||
// add whatever static assignments that have been parsed to the queue
|
// add whatever static assignments that have been parsed to the queue
|
||||||
addStaticAssignmentsToQueue();
|
addStaticAssignmentsToQueue();
|
||||||
|
@ -580,6 +579,11 @@ void DomainServer::processConnectRequestPacket(QSharedPointer<NLPacket> packet)
|
||||||
NodeType_t nodeType;
|
NodeType_t nodeType;
|
||||||
HifiSockAddr publicSockAddr, localSockAddr;
|
HifiSockAddr publicSockAddr, localSockAddr;
|
||||||
|
|
||||||
|
if (packet->getSizeUsed() == 0) {
|
||||||
|
// TODO: We know what size the connect packet should be (minimally) - check for that here
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QDataStream packetStream(packet.data());
|
QDataStream packetStream(packet.data());
|
||||||
|
|
||||||
QUuid connectUUID;
|
QUuid connectUUID;
|
||||||
|
|
|
@ -512,7 +512,7 @@ void NodeList::parseNodeFromPacketStream(QDataStream& packetStream) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeList::sendAssignment(Assignment& assignment) {
|
void NodeList::sendAssignment(Assignment& assignment) {
|
||||||
|
|
||||||
PacketType::Value assignmentPacketType = assignment.getCommand() == Assignment::CreateCommand
|
PacketType::Value assignmentPacketType = assignment.getCommand() == Assignment::CreateCommand
|
||||||
? PacketType::CreateAssignment
|
? PacketType::CreateAssignment
|
||||||
: PacketType::RequestAssignment;
|
: PacketType::RequestAssignment;
|
||||||
|
@ -520,7 +520,6 @@ void NodeList::sendAssignment(Assignment& assignment) {
|
||||||
auto assignmentPacket = NLPacket::create(assignmentPacketType);
|
auto assignmentPacket = NLPacket::create(assignmentPacketType);
|
||||||
|
|
||||||
QDataStream packetStream(assignmentPacket.get());
|
QDataStream packetStream(assignmentPacket.get());
|
||||||
|
|
||||||
packetStream << assignment;
|
packetStream << assignment;
|
||||||
|
|
||||||
// TODO: should this be a non sourced packet?
|
// TODO: should this be a non sourced packet?
|
||||||
|
|
|
@ -61,17 +61,18 @@ qint64 Packet::localHeaderSize() const {
|
||||||
|
|
||||||
Packet::Packet(PacketType::Value type, qint64 size) :
|
Packet::Packet(PacketType::Value type, qint64 size) :
|
||||||
_type(type),
|
_type(type),
|
||||||
_version(0),
|
_version(0)
|
||||||
_packetSize(localHeaderSize(_type) + size),
|
|
||||||
_packet(new char(_packetSize)),
|
|
||||||
_payloadStart(_packet.get() + localHeaderSize(_type)),
|
|
||||||
_capacity(size)
|
|
||||||
{
|
{
|
||||||
auto maxPayload = maxPayloadSize(type);
|
auto maxPayload = maxPayloadSize(type);
|
||||||
if (size == -1) {
|
if (size == -1) {
|
||||||
// default size of -1, means biggest packet possible
|
// default size of -1, means biggest packet possible
|
||||||
size = maxPayload;
|
size = maxPayload;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_packetSize = localHeaderSize(type) + size;
|
||||||
|
_packet.reset(new char(_packetSize));
|
||||||
|
_capacity = size;
|
||||||
|
_payloadStart = _packet.get() + (_packetSize - _capacity);
|
||||||
|
|
||||||
// Sanity check
|
// Sanity check
|
||||||
Q_ASSERT(size >= 0 || size < maxPayload);
|
Q_ASSERT(size >= 0 || size < maxPayload);
|
||||||
|
@ -191,6 +192,7 @@ void Packet::writeSequenceNumber(SequenceNumber seqNum) {
|
||||||
|
|
||||||
static const qint64 PACKET_WRITE_ERROR = -1;
|
static const qint64 PACKET_WRITE_ERROR = -1;
|
||||||
qint64 Packet::writeData(const char* data, qint64 maxSize) {
|
qint64 Packet::writeData(const char* data, qint64 maxSize) {
|
||||||
|
|
||||||
// make sure we have the space required to write this block
|
// make sure we have the space required to write this block
|
||||||
if (maxSize <= bytesAvailableForWrite()) {
|
if (maxSize <= bytesAvailableForWrite()) {
|
||||||
qint64 currentPos = pos();
|
qint64 currentPos = pos();
|
||||||
|
|
Loading…
Reference in a new issue