mirror of
https://github.com/overte-org/overte.git
synced 2025-04-13 19:46:40 +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"
|
||||
|
||||
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) {
|
||||
_node = node;
|
||||
_byteArray = packet;
|
||||
_nlPacket = packet;
|
||||
} else {
|
||||
qCDebug(networking, ">>> NetworkPacket::copyContents() unexpected length = %d", packet.size());
|
||||
}
|
||||
}
|
||||
|
||||
NetworkPacket::NetworkPacket(const NetworkPacket& packet) {
|
||||
copyContents(packet.getNode(), packet.getByteArray());
|
||||
NetworkPacket::NetworkPacket(const NetworkPacket& other) {
|
||||
copyContents(other._node, other._packet);
|
||||
}
|
||||
|
||||
NetworkPacket::NetworkPacket(const SharedNodePointer& node, const QByteArray& packet) {
|
||||
NetworkPacket::NetworkPacket(const SharedNodePointer& node, const NLPacket& packet) {
|
||||
copyContents(node, packet);
|
||||
};
|
||||
|
||||
// copy assignment
|
||||
NetworkPacket& NetworkPacket::operator=(NetworkPacket const& other) {
|
||||
copyContents(other.getNode(), other.getByteArray());
|
||||
copyContents(other._node, other._packet);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#ifdef HAS_MOVE_SEMANTICS
|
||||
// move, same as copy, but other packet won't be used further
|
||||
NetworkPacket::NetworkPacket(NetworkPacket && packet) {
|
||||
copyContents(packet.getNode(), packet.getByteArray());
|
||||
NetworkPacket::NetworkPacket(NetworkPacket&& other) {
|
||||
copyContents(other._node, other._packet);
|
||||
}
|
||||
|
||||
// move assignment
|
||||
NetworkPacket& NetworkPacket::operator=(NetworkPacket&& other) {
|
||||
copyContents(other.getNode(), other.getByteArray());
|
||||
copyContents(other._node, other._packet);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -24,20 +24,20 @@ public:
|
|||
NetworkPacket& operator= (const NetworkPacket& other); // copy assignment
|
||||
|
||||
#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
|
||||
#endif
|
||||
|
||||
NetworkPacket(const SharedNodePointer& node, const QByteArray& byteArray);
|
||||
NetworkPacket(const SharedNodePointer& node, const NLPacket& nlPacket);
|
||||
|
||||
const SharedNodePointer& getNode() const { return _node; }
|
||||
const QByteArray& getByteArray() const { return _byteArray; }
|
||||
const NLPacket& getPacket() const { return _nlPacket; }
|
||||
|
||||
private:
|
||||
void copyContents(const SharedNodePointer& node, const QByteArray& byteArray);
|
||||
void copyContents(const SharedNodePointer& node, const NLPacket& nlPacket);
|
||||
|
||||
SharedNodePointer _node;
|
||||
QByteArray _byteArray;
|
||||
NLPacket _nlPacket;
|
||||
};
|
||||
|
||||
#endif // hifi_NetworkPacket_h
|
||||
|
|
Loading…
Reference in a new issue