sendPacketList first implementation

This commit is contained in:
Atlante45 2015-07-13 12:58:26 -07:00
parent 77bff0c4f2
commit 7a160db8dd
3 changed files with 22 additions and 18 deletions

View file

@ -255,9 +255,7 @@ qint64 LimitedNodeList::sendUnreliablePacket(const NLPacket& packet, const Node&
}
// use the node's active socket as the destination socket
auto destinationSockAddr = destinationNode.getActiveSocket();
return sendUnreliablePacket(packet, *destinationSockAddr);
return sendUnreliablePacket(packet, *destinationNode.getActiveSocket());
}
qint64 LimitedNodeList::sendUnreliablePacket(const NLPacket& packet, const HifiSockAddr& sockAddr) {
@ -271,9 +269,7 @@ qint64 LimitedNodeList::sendPacket(std::unique_ptr<NLPacket> packet, const Node&
}
// use the node's active socket as the destination socket
auto destinationSockAddr = destinationNode.getActiveSocket();
return sendPacket(std::move(packet), *destinationSockAddr);
return sendPacket(std::move(packet), *destinationNode.getActiveSocket());
}
qint64 LimitedNodeList::sendPacket(std::unique_ptr<NLPacket> packet, const HifiSockAddr& sockAddr) {
@ -285,19 +281,26 @@ qint64 LimitedNodeList::sendPacketList(NLPacketList& packetList, const Node& des
// we don't have a socket to send to, return 0
return 0;
}
// use the node's active socket as the destination socket
auto destinationSockAddr = destinationNode.getActiveSocket();
return sendPacketList(packetList, *destinationSockAddr);
return sendPacketList(packetList, *destinationNode.getActiveSocket());
}
qint64 LimitedNodeList::sendPacketList(NLPacketList& packetList, const HifiSockAddr& sockAddr) {
// for (auto packet : packetList) {
//
// }
qint64 bytesSent{ 0 };
auto& packets = packetList._packets;
while (!packets.empty()) {
bytesSent += sendPacket(std::move(packets.front()), sockAddr);
packets.pop_front();
}
assert(false); return 0;
return bytesSent;
}
qint64 LimitedNodeList::sendPacket(std::unique_ptr<NLPacket> packet, const Node& destinationNode,
const HifiSockAddr& overridenSockAddr) {
// use the node's active socket as the destination socket if there is no overriden socket address
auto& destinationSockAddr = (overridenSockAddr.isNull()) ? *destinationNode.getActiveSocket()
: overridenSockAddr;
return sendPacket(std::move(packet), destinationSockAddr);
}
PacketSequenceNumber LimitedNodeList::getNextSequenceNumberForPacket(const QUuid& nodeUUID, PacketType::Value packetType) {

View file

@ -270,9 +270,8 @@ protected:
void sendPacketToIceServer(PacketType::Value packetType, const HifiSockAddr& iceServerSockAddr, const QUuid& clientID,
const QUuid& peerRequestID = QUuid());
qint64 sendPacket(std::unique_ptr<NLPacket> packet, const SharedNodePointer& destinationNode,
const HifiSockAddr& overridenSockAddr)
{ assert(false); return 0; }
qint64 sendPacket(std::unique_ptr<NLPacket> packet, const Node& destinationNode,
const HifiSockAddr& overridenSockAddr);
QUuid _sessionUUID;

View file

@ -41,6 +41,8 @@ protected:
virtual qint64 readData(char* data, qint64 maxSize) { return 0; }
private:
friend class LimitedNodeList;
NLPacketList(const NLPacketList& other) = delete;
NLPacketList& operator=(const NLPacketList& other) = delete;