Merge branch 'protocol' of github.com:birarda/hifi into control-pair-probe

This commit is contained in:
Stephen Birarda 2015-09-01 11:10:06 -06:00
commit 2a8250ced5
21 changed files with 47 additions and 31 deletions

View file

@ -113,11 +113,11 @@ void AssetServer::handleAssetGetInfo(QSharedPointer<NLPacket> packet, SharedNode
if (fileInfo.exists() && fileInfo.isReadable()) {
qDebug() << "Opening file: " << fileInfo.filePath();
replyPacket->writePrimitive(AssetServerError::NO_ERROR);
replyPacket->writePrimitive(AssetServerError::NoError);
replyPacket->writePrimitive(fileInfo.size());
} else {
qDebug() << "Asset not found: " << QString(hexHash);
replyPacket->writePrimitive(AssetServerError::ASSET_NOT_FOUND);
replyPacket->writePrimitive(AssetServerError::AssetNotFound);
}
auto nodeList = DependencyManager::get<NodeList>();
@ -157,7 +157,7 @@ void AssetServer::handleAssetUpload(QSharedPointer<NLPacketList> packetList, Sha
// write the message ID and a permission denied error
permissionErrorPacket->writePrimitive(messageID);
permissionErrorPacket->writePrimitive(AssetServerError::PERMISSION_DENIED);
permissionErrorPacket->writePrimitive(AssetServerError::PermissionDenied);
// send off the packet
auto nodeList = DependencyManager::get<NodeList>();

View file

@ -55,7 +55,7 @@ void SendAssetTask::run() {
replyPacketList->writePrimitive(messageID);
if (end <= start) {
writeError(replyPacketList.get(), AssetServerError::INVALID_BYTE_RANGE);
writeError(replyPacketList.get(), AssetServerError::InvalidByteRange);
} else {
QString filePath = _resourcesDir.filePath(QString(hexHash) + "." + QString(extension));
@ -63,12 +63,12 @@ void SendAssetTask::run() {
if (file.open(QIODevice::ReadOnly)) {
if (file.size() < end) {
writeError(replyPacketList.get(), AssetServerError::INVALID_BYTE_RANGE);
writeError(replyPacketList.get(), AssetServerError::InvalidByteRange);
qCDebug(networking) << "Bad byte range: " << hexHash << " " << start << ":" << end;
} else {
auto size = end - start;
file.seek(start);
replyPacketList->writePrimitive(AssetServerError::NO_ERROR);
replyPacketList->writePrimitive(AssetServerError::NoError);
replyPacketList->writePrimitive(size);
replyPacketList->write(file.read(size));
qCDebug(networking) << "Sending asset: " << hexHash;
@ -76,7 +76,7 @@ void SendAssetTask::run() {
file.close();
} else {
qCDebug(networking) << "Asset not found: " << filePath << "(" << hexHash << ")";
writeError(replyPacketList.get(), AssetServerError::ASSET_NOT_FOUND);
writeError(replyPacketList.get(), AssetServerError::AssetNotFound);
}
}

View file

@ -52,7 +52,7 @@ void UploadAssetTask::run() {
replyPacket->writePrimitive(messageID);
if (fileSize > MAX_UPLOAD_SIZE) {
replyPacket->writePrimitive(AssetServerError::ASSET_TOO_LARGE);
replyPacket->writePrimitive(AssetServerError::AssetTooLarge);
} else {
QByteArray fileData = buffer.read(fileSize);
@ -71,7 +71,7 @@ void UploadAssetTask::run() {
file.write(fileData);
file.close();
}
replyPacket->writePrimitive(AssetServerError::NO_ERROR);
replyPacket->writePrimitive(AssetServerError::NoError);
replyPacket->write(hash);
}

View file

@ -18,11 +18,12 @@
#include <GLMHelpers.h>
#include <SettingHandle.h>
#include <UUID.h>
#include "AddressManager.h"
#include "NodeList.h"
#include "NetworkLogging.h"
#include "UUID.h"
const QString ADDRESS_MANAGER_SETTINGS_GROUP = "AddressManager";
const QString SETTINGS_CURRENT_ADDRESS_KEY = "address";

View file

@ -14,6 +14,8 @@
#include <QBuffer>
#include <QThread>
#include <cstdint>
#include "AssetRequest.h"
#include "AssetUpload.h"
#include "NodeList.h"

View file

@ -52,7 +52,7 @@ void AssetResourceRequest::doSend() {
_data = req->getData();
_result = Success;
break;
case ASSET_NOT_FOUND:
case AssetNotFound:
_result = NotFound;
break;
default:

View file

@ -43,13 +43,13 @@ void AssetUpload::start() {
assetClient->uploadAsset(data, _extension, [this](AssetServerError error, const QString& hash){
switch (error) {
case NO_ERROR:
case AssetServerError::NoError:
_result = Success;
break;
case ASSET_TOO_LARGE:
case AssetServerError::AssetTooLarge:
_result = TooLarge;
break;
case PERMISSION_DENIED:
case AssetServerError::PermissionDenied:
_result = PermissionDenied;
break;
default:

View file

@ -16,6 +16,8 @@
#include <QtCore/QObject>
#include <cstdint>
// You should be able to upload an asset from any thread, and handle the responses in a safe way
// on your own thread. Everything should happen on AssetClient's thread, the caller should
// receive events by connecting to signals on an object that lives on AssetClient's threads.

View file

@ -14,6 +14,8 @@
#include <QtCore/QCryptographicHash>
#include <cstdint>
using MessageID = uint32_t;
using DataOffset = int64_t;
@ -22,11 +24,11 @@ const size_t SHA256_HASH_HEX_LENGTH = 64;
const uint64_t MAX_UPLOAD_SIZE = 1000 * 1000 * 1000; // 1GB
enum AssetServerError : uint8_t {
NO_ERROR = 0,
ASSET_NOT_FOUND,
INVALID_BYTE_RANGE,
ASSET_TOO_LARGE,
PERMISSION_DENIED
NoError,
AssetNotFound,
InvalidByteRange,
AssetTooLarge,
PermissionDenied
};
const QString ATP_SCHEME = "atp";

View file

@ -16,7 +16,8 @@
#include <QtCore/QDebug>
#include <QtCore/QDataStream>
#include "UUID.h"
#include <UUID.h>
#include "NetworkLogging.h"
#include "DataServerAccountInfo.h"

View file

@ -26,11 +26,11 @@
#include <LogHandler.h>
#include <NumericalConstants.h>
#include <SharedUtil.h>
#include <UUID.h>
#include "AccountManager.h"
#include "Assignment.h"
#include "HifiSockAddr.h"
#include "UUID.h"
#include "NetworkLogging.h"
#include "udt/Packet.h"

View file

@ -14,7 +14,8 @@
#include <QtCore/QSharedPointer>
#include "UUID.h"
#include <UUID.h>
#include "udt/Packet.h"
class NLPacket : public udt::Packet {

View file

@ -16,10 +16,11 @@
#include <QtCore/QDataStream>
#include <SharedUtil.h>
#include <UUID.h>
#include "BandwidthRecorder.h"
#include "NetworkLogging.h"
#include "UUID.h"
NetworkPeer::NetworkPeer(QObject* parent) :
QObject(parent),

View file

@ -12,9 +12,10 @@
#include <cstring>
#include <stdio.h>
#include <UUID.h>
#include "Node.h"
#include "SharedUtil.h"
#include "UUID.h"
#include <QtCore/QDataStream>
#include <QtCore/QDebug>

View file

@ -9,6 +9,8 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include "NodeList.h"
#include <QtCore/QDataStream>
#include <QtCore/QDebug>
#include <QtCore/QJsonDocument>
@ -19,17 +21,18 @@
#include <ApplicationVersion.h>
#include <LogHandler.h>
#include <UUID.h>
#include "AccountManager.h"
#include "AddressManager.h"
#include "Assignment.h"
#include "HifiSockAddr.h"
#include "JSONBreakableMarshal.h"
#include "NodeList.h"
#include "NetworkLogging.h"
#include "udt/PacketHeaders.h"
#include "SharedUtil.h"
#include "UUID.h"
#include "NetworkLogging.h"
NodeList::NodeList(char newOwnerType, unsigned short socketListenPort, unsigned short dtlsListenPort) :
LimitedNodeList(socketListenPort, dtlsListenPort),

View file

@ -11,7 +11,8 @@
#include <QtCore/QJsonObject>
#include "UUID.h"
#include <UUID.h>
#include "WalletTransaction.h"

View file

@ -872,7 +872,7 @@ void PendingReceivedMessage::enqueuePacket(std::unique_ptr<Packet> packet) {
// searching from the end of the list.
auto it = find_if(_packets.rbegin(), _packets.rend(),
[&](const std::unique_ptr<Packet>& packet) { return sequenceNumber > packet->getSequenceNumber(); });
}
_packets.insert(it.base(), std::move(packet));
if (_hasFirstSequenceNumber && _hasLastSequenceNumber) {

View file

@ -27,6 +27,8 @@
#define UDT_CONNECTION_DEBUG
class UDTTest;
namespace udt {
class BasePacket;
@ -34,7 +36,6 @@ class ControlSender;
class Packet;
class PacketList;
class SequenceNumber;
class UDTTest;
using PacketFilterOperator = std::function<bool(const Packet&)>;
@ -105,7 +106,7 @@ private:
std::unique_ptr<CongestionControlVirtualFactory> _ccFactory { new CongestionControlFactory<DefaultCC>() };
friend class UDTTest;
friend UDTTest;
};
} // namespace udt