Comment deprecated methods

This commit is contained in:
Atlante45 2015-07-07 16:25:39 -07:00
parent d496b33ae6
commit 833f36e88e

View file

@ -221,18 +221,18 @@ bool LimitedNodeList::packetVersionAndHashMatch(const QByteArray& packet) {
// qint64 LimitedNodeList::readDatagram(char* data, qint64 maxSize, QHostAddress* address = 0, quint16 * port = 0) { // qint64 LimitedNodeList::readDatagram(char* data, qint64 maxSize, QHostAddress* address = 0, quint16 * port = 0) {
qint64 LimitedNodeList::readDatagram(QByteArray& incomingPacket, QHostAddress* address = 0, quint16 * port = 0) { //qint64 LimitedNodeList::readDatagram(QByteArray& incomingPacket, QHostAddress* address = 0, quint16* port = 0) {
qint64 result = getNodeSocket().readDatagram(incomingPacket.data(), incomingPacket.size(), address, port); // qint64 result = getNodeSocket().readDatagram(incomingPacket.data(), incomingPacket.size(), address, port);
//
SharedNodePointer sendingNode = sendingNodeForPacket(incomingPacket); // SharedNodePointer sendingNode = sendingNodeForPacket(incomingPacket);
if (sendingNode) { // if (sendingNode) {
emit dataReceived(sendingNode->getType(), incomingPacket.size()); // emit dataReceived(sendingNode->getType(), incomingPacket.size());
} else { // } else {
emit dataReceived(NodeType::Unassigned, incomingPacket.size()); // emit dataReceived(NodeType::Unassigned, incomingPacket.size());
} // }
//
return result; // return result;
} //}
qint64 LimitedNodeList::writeDatagram(const QByteArray& datagram, const HifiSockAddr& destinationSockAddr) { qint64 LimitedNodeList::writeDatagram(const QByteArray& datagram, const HifiSockAddr& destinationSockAddr) {
// XXX can BandwidthRecorder be used for this? // XXX can BandwidthRecorder be used for this?
@ -250,106 +250,106 @@ qint64 LimitedNodeList::writeDatagram(const QByteArray& datagram, const HifiSock
return bytesWritten; return bytesWritten;
} }
qint64 LimitedNodeList::writeDatagram(const QByteArray& datagram, //qint64 LimitedNodeList::writeDatagram(const QByteArray& datagram,
const SharedNodePointer& destinationNode, // const SharedNodePointer& destinationNode,
const HifiSockAddr& overridenSockAddr) { // const HifiSockAddr& overridenSockAddr) {
if (destinationNode) { // if (destinationNode) {
PacketType::Value packetType = packetTypeForPacket(datagram); // PacketType::Value packetType = packetTypeForPacket(datagram);
//
if (NON_VERIFIED_PACKETS.contains(packetType)) { // if (NON_VERIFIED_PACKETS.contains(packetType)) {
return writeUnverifiedDatagram(datagram, destinationNode, overridenSockAddr); // return writeUnverifiedDatagram(datagram, destinationNode, overridenSockAddr);
} // }
//
// if we don't have an overridden address, assume they want to send to the node's active socket // // if we don't have an overridden address, assume they want to send to the node's active socket
const HifiSockAddr* destinationSockAddr = &overridenSockAddr; // const HifiSockAddr* destinationSockAddr = &overridenSockAddr;
if (overridenSockAddr.isNull()) { // if (overridenSockAddr.isNull()) {
if (destinationNode->getActiveSocket()) { // if (destinationNode->getActiveSocket()) {
// use the node's active socket as the destination socket // // use the node's active socket as the destination socket
destinationSockAddr = destinationNode->getActiveSocket(); // destinationSockAddr = destinationNode->getActiveSocket();
} else { // } else {
// we don't have a socket to send to, return 0 // // we don't have a socket to send to, return 0
return 0; // return 0;
} // }
} // }
//
QByteArray datagramCopy = datagram; // QByteArray datagramCopy = datagram;
//
// if we're here and the connection secret is null, debug out - this could be a problem // // if we're here and the connection secret is null, debug out - this could be a problem
if (destinationNode->getConnectionSecret().isNull()) { // if (destinationNode->getConnectionSecret().isNull()) {
qDebug() << "LimitedNodeList::writeDatagram called for verified datagram with null connection secret for" // qDebug() << "LimitedNodeList::writeDatagram called for verified datagram with null connection secret for"
<< "destination node" << destinationNode->getUUID() << " - this is either not secure or will cause" // << "destination node" << destinationNode->getUUID() << " - this is either not secure or will cause"
<< "this packet to be unverifiable on the receiving side."; // << "this packet to be unverifiable on the receiving side.";
} // }
//
// perform replacement of hash and optionally also sequence number in the header // // perform replacement of hash and optionally also sequence number in the header
if (SEQUENCE_NUMBERED_PACKETS.contains(packetType)) { // if (SEQUENCE_NUMBERED_PACKETS.contains(packetType)) {
PacketSequenceNumber sequenceNumber = getNextSequenceNumberForPacket(destinationNode->getUUID(), packetType); // PacketSequenceNumber sequenceNumber = getNextSequenceNumberForPacket(destinationNode->getUUID(), packetType);
replaceHashAndSequenceNumberInPacket(datagramCopy, destinationNode->getConnectionSecret(), // replaceHashAndSequenceNumberInPacket(datagramCopy, destinationNode->getConnectionSecret(),
sequenceNumber, packetType); // sequenceNumber, packetType);
} else { // } else {
replaceHashInPacket(datagramCopy, destinationNode->getConnectionSecret(), packetType); // replaceHashInPacket(datagramCopy, destinationNode->getConnectionSecret(), packetType);
} // }
//
emit dataSent(destinationNode->getType(), datagram.size()); // emit dataSent(destinationNode->getType(), datagram.size());
auto bytesWritten = writeDatagram(datagramCopy, *destinationSockAddr); // auto bytesWritten = writeDatagram(datagramCopy, *destinationSockAddr);
// Keep track of per-destination-node bandwidth // // Keep track of per-destination-node bandwidth
destinationNode->recordBytesSent(bytesWritten); // destinationNode->recordBytesSent(bytesWritten);
return bytesWritten; // return bytesWritten;
} // }
//
// didn't have a destinationNode to send to, return 0 // // didn't have a destinationNode to send to, return 0
return 0; // return 0;
} //}
//
qint64 LimitedNodeList::writeUnverifiedDatagram(const QByteArray& datagram, const SharedNodePointer& destinationNode, //qint64 LimitedNodeList::writeUnverifiedDatagram(const QByteArray& datagram, const SharedNodePointer& destinationNode,
const HifiSockAddr& overridenSockAddr) { // const HifiSockAddr& overridenSockAddr) {
if (destinationNode) { // if (destinationNode) {
// if we don't have an ovveriden address, assume they want to send to the node's active socket // // if we don't have an ovveriden address, assume they want to send to the node's active socket
const HifiSockAddr* destinationSockAddr = &overridenSockAddr; // const HifiSockAddr* destinationSockAddr = &overridenSockAddr;
if (overridenSockAddr.isNull()) { // if (overridenSockAddr.isNull()) {
if (destinationNode->getActiveSocket()) { // if (destinationNode->getActiveSocket()) {
// use the node's active socket as the destination socket // // use the node's active socket as the destination socket
destinationSockAddr = destinationNode->getActiveSocket(); // destinationSockAddr = destinationNode->getActiveSocket();
} else { // } else {
// we don't have a socket to send to, return 0 // // we don't have a socket to send to, return 0
return 0; // return 0;
} // }
} // }
//
PacketType::Value packetType = packetTypeForPacket(datagram); // PacketType::Value packetType = packetTypeForPacket(datagram);
//
// optionally peform sequence number replacement in the header // // optionally peform sequence number replacement in the header
if (SEQUENCE_NUMBERED_PACKETS.contains(packetType)) { // if (SEQUENCE_NUMBERED_PACKETS.contains(packetType)) {
//
QByteArray datagramCopy = datagram; // QByteArray datagramCopy = datagram;
//
PacketSequenceNumber sequenceNumber = getNextSequenceNumberForPacket(destinationNode->getUUID(), packetType); // PacketSequenceNumber sequenceNumber = getNextSequenceNumberForPacket(destinationNode->getUUID(), packetType);
replaceSequenceNumberInPacket(datagramCopy, sequenceNumber, packetType); // replaceSequenceNumberInPacket(datagramCopy, sequenceNumber, packetType);
//
// send the datagram with sequence number replaced in header // // send the datagram with sequence number replaced in header
return writeDatagram(datagramCopy, *destinationSockAddr); // return writeDatagram(datagramCopy, *destinationSockAddr);
} else { // } else {
return writeDatagram(datagram, *destinationSockAddr); // return writeDatagram(datagram, *destinationSockAddr);
} // }
} // }
//
// didn't have a destinationNode to send to, return 0 // // didn't have a destinationNode to send to, return 0
return 0; // return 0;
} //}
//
qint64 LimitedNodeList::writeUnverifiedDatagram(const QByteArray& datagram, const HifiSockAddr& destinationSockAddr) { //qint64 LimitedNodeList::writeUnverifiedDatagram(const QByteArray& datagram, const HifiSockAddr& destinationSockAddr) {
return writeDatagram(datagram, destinationSockAddr); // return writeDatagram(datagram, destinationSockAddr);
} //}
//
qint64 LimitedNodeList::writeDatagram(const char* data, qint64 size, const SharedNodePointer& destinationNode, //qint64 LimitedNodeList::writeDatagram(const char* data, qint64 size, const SharedNodePointer& destinationNode,
const HifiSockAddr& overridenSockAddr) { // const HifiSockAddr& overridenSockAddr) {
return writeDatagram(QByteArray(data, size), destinationNode, overridenSockAddr); // return writeDatagram(QByteArray(data, size), destinationNode, overridenSockAddr);
} //}
//
qint64 LimitedNodeList::writeUnverifiedDatagram(const char* data, qint64 size, const SharedNodePointer& destinationNode, //qint64 LimitedNodeList::writeUnverifiedDatagram(const char* data, qint64 size, const SharedNodePointer& destinationNode,
const HifiSockAddr& overridenSockAddr) { // const HifiSockAddr& overridenSockAddr) {
return writeUnverifiedDatagram(QByteArray(data, size), destinationNode, overridenSockAddr); // return writeUnverifiedDatagram(QByteArray(data, size), destinationNode, overridenSockAddr);
} //}
PacketSequenceNumber LimitedNodeList::getNextSequenceNumberForPacket(const QUuid& nodeUUID, PacketType::Value packetType) { PacketSequenceNumber LimitedNodeList::getNextSequenceNumberForPacket(const QUuid& nodeUUID, PacketType::Value packetType) {
// Thanks to std::map and std::unordered_map this line either default constructs the // Thanks to std::map and std::unordered_map this line either default constructs the