From 77bff0c4f278103b6927e1a511f1e962ff9a167a Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 13 Jul 2015 11:57:56 -0700 Subject: [PATCH] First draft at sendPacket type method impl --- libraries/networking/src/LimitedNodeList.cpp | 52 ++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index dc08f6d200..b668e91590 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -248,6 +248,58 @@ qint64 LimitedNodeList::writeDatagram(const QByteArray& datagram, const HifiSock return bytesWritten; } +qint64 LimitedNodeList::sendUnreliablePacket(const NLPacket& packet, const Node& destinationNode) { + if (!destinationNode.getActiveSocket()) { + // 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 sendUnreliablePacket(packet, *destinationSockAddr); +} + +qint64 LimitedNodeList::sendUnreliablePacket(const NLPacket& packet, const HifiSockAddr& sockAddr) { + return writeDatagram(packet.getData(), sockAddr); +} + +qint64 LimitedNodeList::sendPacket(std::unique_ptr packet, const Node& destinationNode) { + if (!destinationNode.getActiveSocket()) { + // 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 sendPacket(std::move(packet), *destinationSockAddr); +} + +qint64 LimitedNodeList::sendPacket(std::unique_ptr packet, const HifiSockAddr& sockAddr) { + return writeDatagram(packet->getData(), sockAddr); +} + +qint64 LimitedNodeList::sendPacketList(NLPacketList& packetList, const Node& destinationNode) { + if (!destinationNode.getActiveSocket()) { + // 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); +} + +qint64 LimitedNodeList::sendPacketList(NLPacketList& packetList, const HifiSockAddr& sockAddr) { + // for (auto packet : packetList) { + // + // } + + assert(false); return 0; +} + PacketSequenceNumber LimitedNodeList::getNextSequenceNumberForPacket(const QUuid& nodeUUID, PacketType::Value packetType) { // Thanks to std::map and std::unordered_map this line either default constructs the // PacketType::SequenceMap and the PacketSequenceNumber or returns the existing value.