mirror of
https://github.com/overte-org/overte.git
synced 2025-04-11 13:42:38 +02:00
Merge pull request #1415 from ctrlaltdavid/dev/message-mixer
Networking code tidying and dead code removal.
This commit is contained in:
commit
f5f51dfca7
8 changed files with 10 additions and 27 deletions
|
@ -505,8 +505,8 @@ qint64 LimitedNodeList::sendUnreliableUnorderedPacketList(NLPacketList& packetLi
|
|||
}
|
||||
return bytesSent;
|
||||
} else {
|
||||
qCDebug(networking) << "LimitedNodeList::sendPacketList called without active socket for node" << destinationNode
|
||||
<< " - not sending.";
|
||||
qCDebug(networking) << "LimitedNodeList::sendUnreliableUnorderedPacketList called without active socket for node"
|
||||
<< destinationNode << " - not sending.";
|
||||
return ERROR_SENDING_PACKET_BYTES;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,6 @@ private:
|
|||
|
||||
virtual std::unique_ptr<udt::Packet> createPacket() override;
|
||||
|
||||
|
||||
PacketVersion _packetVersion;
|
||||
NLPacket::LocalID _sourceID;
|
||||
};
|
||||
|
|
|
@ -161,7 +161,7 @@ void PacketReceiver::handleVerifiedMessagePacket(std::unique_ptr<udt::Packet> pa
|
|||
if (!message->isComplete()) {
|
||||
_pendingMessages[key] = message;
|
||||
}
|
||||
handleVerifiedMessage(message, true);
|
||||
handleVerifiedMessage(message, true); // Handler may handle first message packet immediately when it arrives.
|
||||
} else {
|
||||
message = it->second;
|
||||
message->appendPacket(*nlPacket);
|
||||
|
|
|
@ -54,7 +54,7 @@ Connection::Connection(Socket* parentSocket, SockAddr destination, std::unique_p
|
|||
static std::mt19937 generator(rd());
|
||||
static std::uniform_int_distribution<> distribution(0, SequenceNumber::MAX);
|
||||
|
||||
// randomize the intial sequence number
|
||||
// randomize the initial sequence number
|
||||
_initialSequenceNumber = SequenceNumber(distribution(generator));
|
||||
}
|
||||
|
||||
|
@ -255,9 +255,6 @@ bool Connection::processReceivedSequenceNumber(SequenceNumber sequenceNumber, in
|
|||
return false;
|
||||
}
|
||||
|
||||
// mark our last receive time as now (to push the potential expiry farther)
|
||||
_lastReceiveTime = p_high_resolution_clock::now();
|
||||
|
||||
// If this is not the next sequence number, report loss
|
||||
if (sequenceNumber > _lastReceivedSequenceNumber + 1) {
|
||||
if (_lastReceivedSequenceNumber + 1 == sequenceNumber - 1) {
|
||||
|
@ -417,9 +414,6 @@ void Connection::resetReceiveState() {
|
|||
// clear the loss list
|
||||
_lossList.clear();
|
||||
|
||||
// clear sync variables
|
||||
_connectionStart = p_high_resolution_clock::now();
|
||||
|
||||
// clear any pending received messages
|
||||
for (auto& pendingMessage : _pendingReceivedMessages) {
|
||||
_parentSocket->messageFailed(this, pendingMessage.first);
|
||||
|
@ -451,12 +445,6 @@ void PendingReceivedMessage::enqueuePacket(std::unique_ptr<Packet> packet) {
|
|||
"PendingReceivedMessage::enqueuePacket",
|
||||
"called with a packet that is not part of a message");
|
||||
|
||||
if (packet->getPacketPosition() == Packet::PacketPosition::LAST ||
|
||||
packet->getPacketPosition() == Packet::PacketPosition::ONLY) {
|
||||
_hasLastPacket = true;
|
||||
_numPackets = packet->getMessagePartNumber() + 1;
|
||||
}
|
||||
|
||||
// Insert into the packets list in sorted order. Because we generally expect to receive packets in order, begin
|
||||
// searching from the end of the list.
|
||||
auto messagePartNumber = packet->getMessagePartNumber();
|
||||
|
|
|
@ -43,9 +43,7 @@ public:
|
|||
std::list<std::unique_ptr<Packet>> _packets;
|
||||
|
||||
private:
|
||||
bool _hasLastPacket { false };
|
||||
Packet::MessagePartNumber _nextPartNumber = 0;
|
||||
unsigned int _numPackets { 0 };
|
||||
};
|
||||
|
||||
class Connection : public QObject {
|
||||
|
@ -112,9 +110,6 @@ private:
|
|||
bool _hasReceivedHandshakeACK { false }; // flag for receipt of handshake ACK from client
|
||||
bool _didRequestHandshake { false }; // flag for request of handshake from server
|
||||
|
||||
p_high_resolution_clock::time_point _connectionStart = p_high_resolution_clock::now(); // holds the time_point for creation of this connection
|
||||
p_high_resolution_clock::time_point _lastReceiveTime; // holds the last time we received anything from sender
|
||||
|
||||
SequenceNumber _initialSequenceNumber; // Randomized on Connection creation, identifies connection during re-connect requests
|
||||
SequenceNumber _initialReceiveSequenceNumber; // Randomized by peer Connection on creation, identifies connection during re-connect requests
|
||||
|
||||
|
|
|
@ -98,10 +98,11 @@ void ControlPacket::writeType() {
|
|||
void ControlPacket::readType() {
|
||||
ControlBitAndType bitAndType = *reinterpret_cast<ControlBitAndType*>(_packet.get());
|
||||
|
||||
Q_ASSERT_X(bitAndType & CONTROL_BIT_MASK, "ControlPacket::readHeader()", "This should be a control packet");
|
||||
Q_ASSERT_X(bitAndType & CONTROL_BIT_MASK, "ControlPacket::readType()", "This should be a control packet");
|
||||
|
||||
uint16_t packetType = (bitAndType & ~CONTROL_BIT_MASK) >> (8 * sizeof(Type));
|
||||
Q_ASSERT_X(packetType <= ControlPacket::Type::HandshakeRequest, "ControlPacket::readType()", "Received a control packet with wrong type");
|
||||
Q_ASSERT_X(packetType <= ControlPacket::Type::HandshakeRequest, "ControlPacket::readType()",
|
||||
"Received a control packet with invalid type");
|
||||
|
||||
// read the type
|
||||
_type = (Type) packetType;
|
||||
|
|
|
@ -25,8 +25,8 @@ public:
|
|||
using UType = uint32_t;
|
||||
|
||||
// Values are for 27 bit SequenceNumber
|
||||
static const Type THRESHOLD = 0x03FFFFFF; // threshold for comparing sequence numbers
|
||||
static const Type MAX = 0x07FFFFFF; // maximum sequence number used in UDT
|
||||
static const Type THRESHOLD = 0x03FFFFFF; // Threshold for comparing sequence numbers.
|
||||
static const Type MAX = 0x07FFFFFF; // Maximum sequence number used in UDT.
|
||||
|
||||
SequenceNumber() = default;
|
||||
SequenceNumber(const SequenceNumber& other) : _value(other._value) {}
|
||||
|
|
|
@ -207,7 +207,7 @@ qint64 Socket::writePacketList(std::unique_ptr<PacketList> packetList, const Soc
|
|||
return 0;
|
||||
}
|
||||
|
||||
// Unerliable and Unordered
|
||||
// Unreliable and Unordered
|
||||
qint64 totalBytesSent = 0;
|
||||
while (!packetList->_packets.empty()) {
|
||||
totalBytesSent += writePacket(packetList->takeFront<Packet>(), sockAddr);
|
||||
|
|
Loading…
Reference in a new issue