mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 21:57:00 +02:00
Update NetworkPacket to use NLPacket
This commit is contained in:
parent
18dd61ec7e
commit
ebd223ecba
2 changed files with 14 additions and 14 deletions
|
@ -18,38 +18,38 @@
|
||||||
|
|
||||||
#include "NetworkPacket.h"
|
#include "NetworkPacket.h"
|
||||||
|
|
||||||
void NetworkPacket::copyContents(const SharedNodePointer& node, const QByteArray& packet) {
|
void NetworkPacket::copyContents(const SharedNodePointer& node, const NLPacket& packet) {
|
||||||
if (packet.size() && packet.size() <= MAX_PACKET_SIZE) {
|
if (packet.size() && packet.size() <= MAX_PACKET_SIZE) {
|
||||||
_node = node;
|
_node = node;
|
||||||
_byteArray = packet;
|
_nlPacket = packet;
|
||||||
} else {
|
} else {
|
||||||
qCDebug(networking, ">>> NetworkPacket::copyContents() unexpected length = %d", packet.size());
|
qCDebug(networking, ">>> NetworkPacket::copyContents() unexpected length = %d", packet.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkPacket::NetworkPacket(const NetworkPacket& packet) {
|
NetworkPacket::NetworkPacket(const NetworkPacket& other) {
|
||||||
copyContents(packet.getNode(), packet.getByteArray());
|
copyContents(other._node, other._packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkPacket::NetworkPacket(const SharedNodePointer& node, const QByteArray& packet) {
|
NetworkPacket::NetworkPacket(const SharedNodePointer& node, const NLPacket& packet) {
|
||||||
copyContents(node, packet);
|
copyContents(node, packet);
|
||||||
};
|
};
|
||||||
|
|
||||||
// copy assignment
|
// copy assignment
|
||||||
NetworkPacket& NetworkPacket::operator=(NetworkPacket const& other) {
|
NetworkPacket& NetworkPacket::operator=(NetworkPacket const& other) {
|
||||||
copyContents(other.getNode(), other.getByteArray());
|
copyContents(other._node, other._packet);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAS_MOVE_SEMANTICS
|
#ifdef HAS_MOVE_SEMANTICS
|
||||||
// move, same as copy, but other packet won't be used further
|
// move, same as copy, but other packet won't be used further
|
||||||
NetworkPacket::NetworkPacket(NetworkPacket && packet) {
|
NetworkPacket::NetworkPacket(NetworkPacket&& other) {
|
||||||
copyContents(packet.getNode(), packet.getByteArray());
|
copyContents(other._node, other._packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
// move assignment
|
// move assignment
|
||||||
NetworkPacket& NetworkPacket::operator=(NetworkPacket&& other) {
|
NetworkPacket& NetworkPacket::operator=(NetworkPacket&& other) {
|
||||||
copyContents(other.getNode(), other.getByteArray());
|
copyContents(other._node, other._packet);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -24,20 +24,20 @@ public:
|
||||||
NetworkPacket& operator= (const NetworkPacket& other); // copy assignment
|
NetworkPacket& operator= (const NetworkPacket& other); // copy assignment
|
||||||
|
|
||||||
#ifdef HAS_MOVE_SEMANTICS
|
#ifdef HAS_MOVE_SEMANTICS
|
||||||
NetworkPacket(NetworkPacket&& packet); // move?? // same as copy, but other packet won't be used further
|
NetworkPacket(NetworkPacket&& other); // move?? // same as copy, but other packet won't be used further
|
||||||
NetworkPacket& operator= (NetworkPacket&& other); // move assignment
|
NetworkPacket& operator= (NetworkPacket&& other); // move assignment
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
NetworkPacket(const SharedNodePointer& node, const QByteArray& byteArray);
|
NetworkPacket(const SharedNodePointer& node, const NLPacket& nlPacket);
|
||||||
|
|
||||||
const SharedNodePointer& getNode() const { return _node; }
|
const SharedNodePointer& getNode() const { return _node; }
|
||||||
const QByteArray& getByteArray() const { return _byteArray; }
|
const NLPacket& getPacket() const { return _nlPacket; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void copyContents(const SharedNodePointer& node, const QByteArray& byteArray);
|
void copyContents(const SharedNodePointer& node, const NLPacket& nlPacket);
|
||||||
|
|
||||||
SharedNodePointer _node;
|
SharedNodePointer _node;
|
||||||
QByteArray _byteArray;
|
NLPacket _nlPacket;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_NetworkPacket_h
|
#endif // hifi_NetworkPacket_h
|
||||||
|
|
Loading…
Reference in a new issue