mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 21:30:33 +02:00
Merge branch 'atp' of https://github.com/birarda/hifi into protocol
This commit is contained in:
commit
d6ea493975
37 changed files with 188 additions and 184 deletions
|
@ -56,7 +56,7 @@ void Agent::readPendingDatagrams() {
|
|||
|
||||
while (readAvailableDatagram(receivedPacket, senderSockAddr)) {
|
||||
if (nodeList->packetVersionAndHashMatch(receivedPacket)) {
|
||||
PacketType datagramPacketType = packetTypeForPacket(receivedPacket);
|
||||
PacketType::Value datagramPacketType = packetTypeForPacket(receivedPacket);
|
||||
|
||||
if (datagramPacketType == PacketTypeJurisdiction) {
|
||||
int headerBytes = numBytesForPacketHeader(receivedPacket);
|
||||
|
|
|
@ -535,7 +535,7 @@ void AudioMixer::readPendingDatagram(const QByteArray& receivedPacket, const Hif
|
|||
|
||||
if (nodeList->packetVersionAndHashMatch(receivedPacket)) {
|
||||
// pull any new audio data from nodes off of the network stack
|
||||
PacketType mixerPacketType = packetTypeForPacket(receivedPacket);
|
||||
PacketType::Value mixerPacketType = packetTypeForPacket(receivedPacket);
|
||||
if (mixerPacketType == PacketTypeMicrophoneAudioNoEcho
|
||||
|| mixerPacketType == PacketTypeMicrophoneAudioWithEcho
|
||||
|| mixerPacketType == PacketTypeInjectAudio
|
||||
|
|
|
@ -50,7 +50,7 @@ AvatarAudioStream* AudioMixerClientData::getAvatarAudioStream() const {
|
|||
}
|
||||
|
||||
int AudioMixerClientData::parseData(const QByteArray& packet) {
|
||||
PacketType packetType = packetTypeForPacket(packet);
|
||||
PacketType::Value packetType = packetTypeForPacket(packet);
|
||||
if (packetType == PacketTypeAudioStreamStats) {
|
||||
|
||||
const char* dataAt = packet.data();
|
||||
|
|
|
@ -22,7 +22,7 @@ public:
|
|||
OctreeQueryNode(),
|
||||
_lastDeletedEntitiesSentAt(0) { }
|
||||
|
||||
virtual PacketType getMyPacketType() const { return PacketTypeEntityData; }
|
||||
virtual PacketType::Value getMyPacketType() const { return PacketTypeEntityData; }
|
||||
|
||||
quint64 getLastDeletedEntitiesSentAt() const { return _lastDeletedEntitiesSentAt; }
|
||||
void setLastDeletedEntitiesSentAt(quint64 sentAt) { _lastDeletedEntitiesSentAt = sentAt; }
|
||||
|
|
|
@ -28,11 +28,11 @@ public:
|
|||
// Subclasses must implement these methods
|
||||
virtual OctreeQueryNode* createOctreeQueryNode();
|
||||
virtual char getMyNodeType() const { return NodeType::EntityServer; }
|
||||
virtual PacketType getMyQueryMessageType() const { return PacketTypeEntityQuery; }
|
||||
virtual PacketType::Value getMyQueryMessageType() const { return PacketTypeEntityQuery; }
|
||||
virtual const char* getMyServerName() const { return MODEL_SERVER_NAME; }
|
||||
virtual const char* getMyLoggingServerTargetName() const { return MODEL_SERVER_LOGGING_TARGET_NAME; }
|
||||
virtual const char* getMyDefaultPersistFilename() const { return LOCAL_MODELS_PERSIST_FILE; }
|
||||
virtual PacketType getMyEditNackType() const { return PacketTypeEntityEditNack; }
|
||||
virtual PacketType::Value getMyEditNackType() const { return PacketTypeEntityEditNack; }
|
||||
virtual QString getMyDomainSettingsKey() const { return QString("entity_server_settings"); }
|
||||
|
||||
// subclass may implement these method
|
||||
|
|
|
@ -90,7 +90,7 @@ void OctreeInboundPacketProcessor::processPacket(const SharedNodePointer& sendin
|
|||
|
||||
|
||||
// Ask our tree subclass if it can handle the incoming packet...
|
||||
PacketType packetType = packetTypeForPacket(packet);
|
||||
PacketType::Value packetType = packetTypeForPacket(packet);
|
||||
if (_myServer->getOctree()->handlesEditPacketType(packetType)) {
|
||||
PerformanceWarning warn(debugProcessPacket, "processPacket KNOWN TYPE",debugProcessPacket);
|
||||
_receivedPacketCount++;
|
||||
|
|
|
@ -35,7 +35,7 @@ public:
|
|||
virtual ~OctreeQueryNode();
|
||||
|
||||
void init(); // called after creation to set up some virtual items
|
||||
virtual PacketType getMyPacketType() const = 0;
|
||||
virtual PacketType::Value getMyPacketType() const = 0;
|
||||
|
||||
void resetOctreePacket(); // resets octree packet to after "V" header
|
||||
|
||||
|
@ -155,7 +155,7 @@ private:
|
|||
|
||||
quint64 _lastRootTimestamp;
|
||||
|
||||
PacketType _myPacketType;
|
||||
PacketType::Value _myPacketType;
|
||||
bool _isShuttingDown;
|
||||
|
||||
SentPacketHistory _sentPacketHistory;
|
||||
|
|
|
@ -862,7 +862,7 @@ void OctreeServer::readPendingDatagram(const QByteArray& receivedPacket, const H
|
|||
|
||||
if (!_isShuttingDown) {
|
||||
if (nodeList->packetVersionAndHashMatch(receivedPacket)) {
|
||||
PacketType packetType = packetTypeForPacket(receivedPacket);
|
||||
PacketType::Value packetType = packetTypeForPacket(receivedPacket);
|
||||
SharedNodePointer matchingNode = nodeList->sendingNodeForPacket(receivedPacket);
|
||||
if (packetType == getMyQueryMessageType()) {
|
||||
// If we got a query packet, then we're talking to an agent, and we
|
||||
|
|
|
@ -63,11 +63,11 @@ public:
|
|||
// Subclasses must implement these methods
|
||||
virtual OctreeQueryNode* createOctreeQueryNode() = 0;
|
||||
virtual char getMyNodeType() const = 0;
|
||||
virtual PacketType getMyQueryMessageType() const = 0;
|
||||
virtual PacketType::Value getMyQueryMessageType() const = 0;
|
||||
virtual const char* getMyServerName() const = 0;
|
||||
virtual const char* getMyLoggingServerTargetName() const = 0;
|
||||
virtual const char* getMyDefaultPersistFilename() const = 0;
|
||||
virtual PacketType getMyEditNackType() const = 0;
|
||||
virtual PacketType::Value getMyEditNackType() const = 0;
|
||||
virtual QString getMyDomainSettingsKey() const { return QString("octree_server_settings"); }
|
||||
|
||||
// subclass may implement these method
|
||||
|
|
|
@ -43,7 +43,7 @@ void OctreeServerDatagramProcessor::readPendingDatagrams() {
|
|||
_nodeSocket.readDatagram(incomingPacket.data(), incomingPacket.size(),
|
||||
senderSockAddr.getAddressPointer(), senderSockAddr.getPortPointer());
|
||||
|
||||
PacketType packetType = packetTypeForPacket(incomingPacket);
|
||||
PacketType::Value packetType = packetTypeForPacket(incomingPacket);
|
||||
if (packetType == PacketTypePing) {
|
||||
DependencyManager::get<NodeList>()->processNodeData(senderSockAddr, incomingPacket);
|
||||
return; // don't emit
|
||||
|
|
|
@ -1390,7 +1390,7 @@ void DomainServer::processDatagram(const QByteArray& receivedPacket, const HifiS
|
|||
auto nodeList = DependencyManager::get<LimitedNodeList>();
|
||||
|
||||
if (nodeList->packetVersionAndHashMatch(receivedPacket)) {
|
||||
PacketType requestType = packetTypeForPacket(receivedPacket);
|
||||
PacketType::Value requestType = packetTypeForPacket(receivedPacket);
|
||||
switch (requestType) {
|
||||
case PacketTypeDomainConnectRequest:
|
||||
handleConnectRequest(receivedPacket, senderSockAddr);
|
||||
|
|
|
@ -54,7 +54,7 @@ void IceServer::processDatagrams() {
|
|||
_serverSocket.readDatagram(incomingPacket.data(), incomingPacket.size(),
|
||||
sendingSockAddr.getAddressPointer(), sendingSockAddr.getPortPointer());
|
||||
|
||||
PacketType packetType = packetTypeForPacket(incomingPacket);
|
||||
PacketType::Value packetType = packetTypeForPacket(incomingPacket);
|
||||
|
||||
if (packetType == PacketTypeIceServerHeartbeat) {
|
||||
SharedNetworkPeer peer = addOrUpdateHeartbeatingPeer(incomingPacket);
|
||||
|
|
|
@ -2729,7 +2729,7 @@ int Application::sendNackPackets() {
|
|||
return packetsSent;
|
||||
}
|
||||
|
||||
void Application::queryOctree(NodeType_t serverType, PacketType packetType, NodeToJurisdictionMap& jurisdictions) {
|
||||
void Application::queryOctree(NodeType_t serverType, PacketType::Value packetType, NodeToJurisdictionMap& jurisdictions) {
|
||||
|
||||
//qCDebug(interfaceapp) << ">>> inside... queryOctree()... _viewFrustum.getFieldOfView()=" << _viewFrustum.getFieldOfView();
|
||||
bool wantExtraDebugging = getLogger()->extraDebugging();
|
||||
|
|
|
@ -511,7 +511,7 @@ private:
|
|||
|
||||
void renderLookatIndicator(glm::vec3 pointOfInterest);
|
||||
|
||||
void queryOctree(NodeType_t serverType, PacketType packetType, NodeToJurisdictionMap& jurisdictions);
|
||||
void queryOctree(NodeType_t serverType, PacketType::Value packetType, NodeToJurisdictionMap& jurisdictions);
|
||||
void loadViewFrustum(Camera& camera, ViewFrustum& viewFrustum);
|
||||
|
||||
glm::vec3 getSunDirection();
|
||||
|
|
|
@ -52,7 +52,7 @@ void DatagramProcessor::processDatagrams() {
|
|||
|
||||
if (nodeList->packetVersionAndHashMatch(incomingPacket)) {
|
||||
|
||||
PacketType incomingType = packetTypeForPacket(incomingPacket);
|
||||
PacketType::Value incomingType = packetTypeForPacket(incomingPacket);
|
||||
// only process this packet if we have a match on the packet version
|
||||
switch (incomingType) {
|
||||
case PacketTypeAudioEnvironment:
|
||||
|
|
|
@ -33,7 +33,7 @@ void OctreePacketProcessor::processPacket(const SharedNodePointer& sendingNode,
|
|||
bool wasStatsPacket = false;
|
||||
|
||||
|
||||
PacketType voxelPacketType = packetTypeForPacket(mutablePacket);
|
||||
PacketType::Value voxelPacketType = packetTypeForPacket(mutablePacket);
|
||||
|
||||
// note: PacketType_OCTREE_STATS can have PacketType_VOXEL_DATA
|
||||
// immediately following them inside the same packet. So, we process the PacketType_OCTREE_STATS first
|
||||
|
|
|
@ -844,7 +844,7 @@ void AudioClient::handleAudioInput() {
|
|||
glm::quat headOrientation = _orientationGetter();
|
||||
quint8 isStereo = _isStereoInput ? 1 : 0;
|
||||
|
||||
PacketType packetType;
|
||||
PacketType::Value packetType;
|
||||
if (_lastInputLoudness == 0) {
|
||||
packetType = PacketTypeSilentAudioFrame;
|
||||
} else {
|
||||
|
|
|
@ -98,7 +98,7 @@ void InboundAudioStream::perSecondCallbackForUpdatingStats() {
|
|||
|
||||
int InboundAudioStream::parseData(const QByteArray& packet) {
|
||||
|
||||
PacketType packetType = packetTypeForPacket(packet);
|
||||
PacketType::Value packetType = packetTypeForPacket(packet);
|
||||
QUuid senderUUID = uuidFromPacketHeader(packet);
|
||||
|
||||
// parse header
|
||||
|
|
|
@ -43,8 +43,8 @@ public:
|
|||
virtual ~EntityTreeRenderer();
|
||||
|
||||
virtual char getMyNodeType() const { return NodeType::EntityServer; }
|
||||
virtual PacketType getMyQueryMessageType() const { return PacketTypeEntityQuery; }
|
||||
virtual PacketType getExpectedPacketType() const { return PacketTypeEntityData; }
|
||||
virtual PacketType::Value getMyQueryMessageType() const { return PacketTypeEntityQuery; }
|
||||
virtual PacketType::Value getExpectedPacketType() const { return PacketTypeEntityData; }
|
||||
virtual void renderElement(OctreeElement* element, RenderArgs* args);
|
||||
virtual float getSizeScale() const;
|
||||
virtual int getBoundaryLevelAdjust() const;
|
||||
|
|
|
@ -62,7 +62,7 @@ public:
|
|||
// These methods will allow the OctreeServer to send your tree inbound edit packets of your
|
||||
// own definition. Implement these to allow your octree based server to support editing
|
||||
virtual bool getWantSVOfileVersions() const { return true; }
|
||||
virtual PacketType expectedDataPacketType() const { return PacketTypeEntityData; }
|
||||
virtual PacketType::Value expectedDataPacketType() const { return PacketTypeEntityData; }
|
||||
virtual bool canProcessVersion(PacketVersion thisVersion) const
|
||||
{ return thisVersion >= VERSION_ENTITIES_USE_METERS_AND_RADIANS; }
|
||||
virtual bool handlesEditPacketType(PacketType packetType) const;
|
||||
|
|
|
@ -31,8 +31,8 @@ public:
|
|||
virtual ~EntityTreeHeadlessViewer();
|
||||
|
||||
virtual char getMyNodeType() const { return NodeType::EntityServer; }
|
||||
virtual PacketType getMyQueryMessageType() const { return PacketTypeEntityQuery; }
|
||||
virtual PacketType getExpectedPacketType() const { return PacketTypeEntityData; }
|
||||
virtual PacketType::Value getMyQueryMessageType() const { return PacketTypeEntityQuery; }
|
||||
virtual PacketType::Value getExpectedPacketType() const { return PacketTypeEntityData; }
|
||||
|
||||
void update();
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ Assignment::Assignment(const QByteArray& packet) :
|
|||
_payload(),
|
||||
_walletUUID()
|
||||
{
|
||||
PacketType packetType = packetTypeForPacket(packet);
|
||||
PacketType::Value packetType = packetTypeForPacket(packet);
|
||||
|
||||
if (packetType == PacketTypeRequestAssignment) {
|
||||
_command = Assignment::RequestCommand;
|
||||
|
|
|
@ -164,12 +164,12 @@ void LimitedNodeList::changeSocketBufferSizes(int numBytes) {
|
|||
}
|
||||
|
||||
bool LimitedNodeList::packetVersionAndHashMatch(const QByteArray& packet) {
|
||||
PacketType checkType = packetTypeForPacket(packet);
|
||||
PacketType::Value checkType = packetTypeForPacket(packet);
|
||||
int numPacketTypeBytes = numBytesArithmeticCodingFromBuffer(packet.data());
|
||||
|
||||
if (packet[numPacketTypeBytes] != versionForPacketType(checkType)
|
||||
&& checkType != PacketTypeStunResponse) {
|
||||
PacketType mismatchType = packetTypeForPacket(packet);
|
||||
PacketType::Value mismatchType = packetTypeForPacket(packet);
|
||||
|
||||
static QMultiMap<QUuid, PacketType> versionDebugSuppressMap;
|
||||
|
||||
|
@ -254,7 +254,7 @@ qint64 LimitedNodeList::writeDatagram(const QByteArray& datagram,
|
|||
const SharedNodePointer& destinationNode,
|
||||
const HifiSockAddr& overridenSockAddr) {
|
||||
if (destinationNode) {
|
||||
PacketType packetType = packetTypeForPacket(datagram);
|
||||
PacketType::Value packetType = packetTypeForPacket(datagram);
|
||||
|
||||
if (NON_VERIFIED_PACKETS.contains(packetType)) {
|
||||
return writeUnverifiedDatagram(datagram, destinationNode, overridenSockAddr);
|
||||
|
@ -316,7 +316,7 @@ qint64 LimitedNodeList::writeUnverifiedDatagram(const QByteArray& datagram, cons
|
|||
}
|
||||
}
|
||||
|
||||
PacketType packetType = packetTypeForPacket(datagram);
|
||||
PacketType::Value packetType = packetTypeForPacket(datagram);
|
||||
|
||||
// optionally peform sequence number replacement in the header
|
||||
if (SEQUENCE_NUMBERED_PACKETS.contains(packetType)) {
|
||||
|
@ -351,7 +351,7 @@ qint64 LimitedNodeList::writeUnverifiedDatagram(const char* data, qint64 size, c
|
|||
return writeUnverifiedDatagram(QByteArray(data, size), destinationNode, overridenSockAddr);
|
||||
}
|
||||
|
||||
PacketSequenceNumber LimitedNodeList::getNextSequenceNumberForPacket(const QUuid& nodeUUID, PacketType packetType) {
|
||||
PacketSequenceNumber LimitedNodeList::getNextSequenceNumberForPacket(const QUuid& nodeUUID, PacketType::Value packetType) {
|
||||
// Thanks to std::map and std::unordered_map this line either default constructs the
|
||||
// PacketTypeSequenceMap and the PacketSequenceNumber or returns the existing value.
|
||||
// We use the postfix increment so that the stored value is incremented and the next
|
||||
|
@ -376,7 +376,7 @@ int LimitedNodeList::updateNodeWithDataFromPacket(const SharedNodePointer& match
|
|||
|
||||
// if this was a sequence numbered packet we should store the last seq number for
|
||||
// a packet of this type for this node
|
||||
PacketType packetType = packetTypeForPacket(packet);
|
||||
PacketType::Value packetType = packetTypeForPacket(packet);
|
||||
if (SEQUENCE_NUMBERED_PACKETS.contains(packetType)) {
|
||||
matchingNode->setLastSequenceNumberForPacketType(sequenceNumberFromHeader(packet, packetType), packetType);
|
||||
}
|
||||
|
@ -546,7 +546,7 @@ QByteArray LimitedNodeList::constructPingReplyPacket(const QByteArray& pingPacke
|
|||
quint64 timeFromOriginalPing;
|
||||
pingPacketStream >> timeFromOriginalPing;
|
||||
|
||||
PacketType replyType = (packetTypeForPacket(pingPacket) == PacketTypePing)
|
||||
PacketType::Value replyType = (packetTypeForPacket(pingPacket) == PacketTypePing)
|
||||
? PacketTypePingReply : PacketTypeUnverifiedPingReply;
|
||||
|
||||
QUuid packetUUID = packetHeaderID.isNull() ? _sessionUUID : packetHeaderID;
|
||||
|
|
|
@ -118,12 +118,12 @@ public:
|
|||
|
||||
bool packetVersionAndHashMatch(const QByteArray& packet);
|
||||
|
||||
QByteArray byteArrayWithPopulatedHeader(PacketType packetType)
|
||||
{ return byteArrayWithUUIDPopulatedHeader(packetType, _sessionUUID); }
|
||||
int populatePacketHeader(QByteArray& packet, PacketType packetType)
|
||||
{ return populatePacketHeaderWithUUID(packet, packetType, _sessionUUID); }
|
||||
int populatePacketHeader(char* packet, PacketType packetType)
|
||||
{ return populatePacketHeaderWithUUID(packet, packetType, _sessionUUID); }
|
||||
// QByteArray byteArrayWithPopulatedHeader(PacketType packetType)
|
||||
// { return byteArrayWithUUIDPopulatedHeader(packetType, _sessionUUID); }
|
||||
// int populatePacketHeader(QByteArray& packet, PacketType::Value packetType)
|
||||
// { return populatePacketHeaderWithUUID(packet, packetType, _sessionUUID); }
|
||||
// int populatePacketHeader(char* packet, PacketType::Value packetType)
|
||||
// { return populatePacketHeaderWithUUID(packet, packetType, _sessionUUID); }
|
||||
|
||||
qint64 readDatagram(QByteArray& incomingPacket, QHostAddress* address, quint16 * port);
|
||||
|
||||
|
@ -266,7 +266,7 @@ protected:
|
|||
|
||||
qint64 writeDatagram(const QByteArray& datagram, const HifiSockAddr& destinationSockAddr);
|
||||
|
||||
PacketSequenceNumber getNextSequenceNumberForPacket(const QUuid& nodeUUID, PacketType packetType);
|
||||
PacketSequenceNumber getNextSequenceNumberForPacket(const QUuid& nodeUUID, PacketType::Value packetType);
|
||||
|
||||
void changeSocketBufferSizes(int numBytes);
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ public:
|
|||
void setCanRez(bool canRez) { _canRez = canRez; }
|
||||
bool getCanRez() { return _canRez; }
|
||||
|
||||
void setLastSequenceNumberForPacketType(PacketSequenceNumber sequenceNumber, PacketType packetType)
|
||||
void setLastSequenceNumberForPacketType(PacketSequenceNumber sequenceNumber, PacketType::Value packetType)
|
||||
{ _lastSequenceNumbers[packetType] = sequenceNumber; }
|
||||
PacketSequenceNumber getLastSequenceNumberForPacketType(PacketType packetType) const;
|
||||
|
||||
|
|
|
@ -173,7 +173,7 @@ void NodeList::timePingReply(const QByteArray& packet, const SharedNodePointer&
|
|||
}
|
||||
|
||||
void NodeList::processNodeData(const HifiSockAddr& senderSockAddr, const QByteArray& packet) {
|
||||
PacketType packetType = packetTypeForPacket(packet);
|
||||
PacketType::Value packetType = packetTypeForPacket(packet);
|
||||
switch (packetType) {
|
||||
case PacketTypeDomainList:
|
||||
case PacketTypeDomainServerAddedNode: {
|
||||
|
@ -309,7 +309,7 @@ void NodeList::sendDomainServerCheckIn() {
|
|||
} else if (!_domainHandler.getIP().isNull()) {
|
||||
bool isUsingDTLS = false;
|
||||
|
||||
PacketType domainPacketType = !_domainHandler.isConnected()
|
||||
PacketType::Value domainPacketType = !_domainHandler.isConnected()
|
||||
? PacketTypeDomainConnectRequest : PacketTypeDomainListRequest;
|
||||
|
||||
if (!_domainHandler.isConnected()) {
|
||||
|
@ -600,7 +600,7 @@ void NodeList::parseNodeFromPacketStream(QDataStream& packetStream) {
|
|||
|
||||
void NodeList::sendAssignment(Assignment& assignment) {
|
||||
|
||||
PacketType assignmentPacketType = assignment.getCommand() == Assignment::CreateCommand
|
||||
PacketType::Value assignmentPacketType = assignment.getCommand() == Assignment::CreateCommand
|
||||
? PacketTypeCreateAssignment
|
||||
: PacketTypeRequestAssignment;
|
||||
|
||||
|
|
|
@ -15,6 +15,22 @@
|
|||
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
using namespace PacketType;
|
||||
|
||||
const QSet<PacketType::Value> NON_VERIFIED_PACKETS = QSet<PacketType::Value>()
|
||||
<< DomainServerRequireDTLS << DomainConnectRequest
|
||||
<< DomainList << DomainListRequest << DomainConnectionDenied
|
||||
<< CreateAssignment << RequestAssignment << StunResponse
|
||||
<< NodeJsonStats << EntityQuery
|
||||
<< OctreeDataNack << EntityEditNack
|
||||
<< IceServerHeartbeat << IceServerPeerInformation
|
||||
<< IceServerQuery << UnverifiedPing
|
||||
<< UnverifiedPingReply << StopNode
|
||||
<< DomainServerPathQuery << DomainServerPathResponse
|
||||
<< DomainServerAddedNode;
|
||||
|
||||
const QSet<PacketType::Value> SEQUENCE_NUMBERED_PACKETS = QSet<PacketType::Value>() << AvatarData;
|
||||
|
||||
int arithmeticCodingValueFromBuffer(const char* checkValue) {
|
||||
if (((uchar) *checkValue) < 255) {
|
||||
return *checkValue;
|
||||
|
@ -43,43 +59,43 @@ int packArithmeticallyCodedValue(int value, char* destination) {
|
|||
}
|
||||
}
|
||||
|
||||
PacketVersion versionForPacketType(PacketType packetType) {
|
||||
PacketVersion versionForPacketType(PacketType::Value packetType) {
|
||||
switch (packetType) {
|
||||
case PacketTypeMicrophoneAudioNoEcho:
|
||||
case PacketTypeMicrophoneAudioWithEcho:
|
||||
case MicrophoneAudioNoEcho:
|
||||
case MicrophoneAudioWithEcho:
|
||||
return 2;
|
||||
case PacketTypeSilentAudioFrame:
|
||||
case SilentAudioFrame:
|
||||
return 4;
|
||||
case PacketTypeMixedAudio:
|
||||
case MixedAudio:
|
||||
return 1;
|
||||
case PacketTypeInjectAudio:
|
||||
case InjectAudio:
|
||||
return 1;
|
||||
case PacketTypeAvatarData:
|
||||
case AvatarData:
|
||||
return 6;
|
||||
case PacketTypeAvatarIdentity:
|
||||
case AvatarIdentity:
|
||||
return 1;
|
||||
case PacketTypeEnvironmentData:
|
||||
case EnvironmentData:
|
||||
return 2;
|
||||
case PacketTypeDomainList:
|
||||
case PacketTypeDomainListRequest:
|
||||
case DomainList:
|
||||
case DomainListRequest:
|
||||
return 5;
|
||||
case PacketTypeCreateAssignment:
|
||||
case PacketTypeRequestAssignment:
|
||||
case CreateAssignment:
|
||||
case RequestAssignment:
|
||||
return 2;
|
||||
case PacketTypeOctreeStats:
|
||||
case OctreeStats:
|
||||
return 1;
|
||||
case PacketTypeStopNode:
|
||||
case StopNode:
|
||||
return 1;
|
||||
case PacketTypeEntityAdd:
|
||||
case PacketTypeEntityEdit:
|
||||
case PacketTypeEntityData:
|
||||
case EntityAdd:
|
||||
case EntityEdit:
|
||||
case EntityData:
|
||||
return VERSION_ENTITIES_HAVE_SIMULATION_OWNER_AND_ACTIONS_OVER_WIRE;
|
||||
case PacketTypeEntityErase:
|
||||
case EntityErase:
|
||||
return 2;
|
||||
case PacketTypeAudioStreamStats:
|
||||
case AudioStreamStats:
|
||||
return 1;
|
||||
case PacketTypeIceServerHeartbeat:
|
||||
case PacketTypeIceServerQuery:
|
||||
case IceServerHeartbeat:
|
||||
case IceServerQuery:
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
|
@ -88,53 +104,53 @@ PacketVersion versionForPacketType(PacketType packetType) {
|
|||
|
||||
#define PACKET_TYPE_NAME_LOOKUP(x) case x: return QString(#x);
|
||||
|
||||
QString nameForPacketType(PacketType packetType) {
|
||||
QString nameForPacketType(PacketType::Value packetType) {
|
||||
switch (packetType) {
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeUnknown);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeStunResponse);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeDomainList);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypePing);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypePingReply);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeKillAvatar);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeAvatarData);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeInjectAudio);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeMixedAudio);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeMicrophoneAudioNoEcho);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeMicrophoneAudioWithEcho);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeBulkAvatarData);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeSilentAudioFrame);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeEnvironmentData);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeDomainListRequest);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeRequestAssignment);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeCreateAssignment);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeDomainConnectionDenied);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeMuteEnvironment);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeAudioStreamStats);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeDataServerConfirm);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeOctreeStats);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeJurisdiction);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeJurisdictionRequest);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeAvatarIdentity);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeAvatarBillboard);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeDomainConnectRequest);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeDomainServerRequireDTLS);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeNodeJsonStats);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeEntityQuery);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeEntityData);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeEntityErase);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeOctreeDataNack);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeStopNode);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeAudioEnvironment);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeEntityEditNack);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeSignedTransactionPayment);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeIceServerHeartbeat);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeDomainServerAddedNode);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeIceServerQuery);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeIceServerPeerInformation);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeUnverifiedPing);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeUnverifiedPingReply);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeEntityAdd);
|
||||
PACKET_TYPE_NAME_LOOKUP(PacketTypeEntityEdit);
|
||||
PACKET_TYPE_NAME_LOOKUP(Unknown);
|
||||
PACKET_TYPE_NAME_LOOKUP(StunResponse);
|
||||
PACKET_TYPE_NAME_LOOKUP(DomainList);
|
||||
PACKET_TYPE_NAME_LOOKUP(Ping);
|
||||
PACKET_TYPE_NAME_LOOKUP(PingReply);
|
||||
PACKET_TYPE_NAME_LOOKUP(KillAvatar);
|
||||
PACKET_TYPE_NAME_LOOKUP(AvatarData);
|
||||
PACKET_TYPE_NAME_LOOKUP(InjectAudio);
|
||||
PACKET_TYPE_NAME_LOOKUP(MixedAudio);
|
||||
PACKET_TYPE_NAME_LOOKUP(MicrophoneAudioNoEcho);
|
||||
PACKET_TYPE_NAME_LOOKUP(MicrophoneAudioWithEcho);
|
||||
PACKET_TYPE_NAME_LOOKUP(BulkAvatarData);
|
||||
PACKET_TYPE_NAME_LOOKUP(SilentAudioFrame);
|
||||
PACKET_TYPE_NAME_LOOKUP(EnvironmentData);
|
||||
PACKET_TYPE_NAME_LOOKUP(DomainListRequest);
|
||||
PACKET_TYPE_NAME_LOOKUP(RequestAssignment);
|
||||
PACKET_TYPE_NAME_LOOKUP(CreateAssignment);
|
||||
PACKET_TYPE_NAME_LOOKUP(DomainConnectionDenied);
|
||||
PACKET_TYPE_NAME_LOOKUP(MuteEnvironment);
|
||||
PACKET_TYPE_NAME_LOOKUP(AudioStreamStats);
|
||||
PACKET_TYPE_NAME_LOOKUP(DataServerConfirm);
|
||||
PACKET_TYPE_NAME_LOOKUP(OctreeStats);
|
||||
PACKET_TYPE_NAME_LOOKUP(Jurisdiction);
|
||||
PACKET_TYPE_NAME_LOOKUP(JurisdictionRequest);
|
||||
PACKET_TYPE_NAME_LOOKUP(AvatarIdentity);
|
||||
PACKET_TYPE_NAME_LOOKUP(AvatarBillboard);
|
||||
PACKET_TYPE_NAME_LOOKUP(DomainConnectRequest);
|
||||
PACKET_TYPE_NAME_LOOKUP(DomainServerRequireDTLS);
|
||||
PACKET_TYPE_NAME_LOOKUP(NodeJsonStats);
|
||||
PACKET_TYPE_NAME_LOOKUP(EntityQuery);
|
||||
PACKET_TYPE_NAME_LOOKUP(EntityData);
|
||||
PACKET_TYPE_NAME_LOOKUP(EntityErase);
|
||||
PACKET_TYPE_NAME_LOOKUP(OctreeDataNack);
|
||||
PACKET_TYPE_NAME_LOOKUP(StopNode);
|
||||
PACKET_TYPE_NAME_LOOKUP(AudioEnvironment);
|
||||
PACKET_TYPE_NAME_LOOKUP(EntityEditNack);
|
||||
PACKET_TYPE_NAME_LOOKUP(SignedTransactionPayment);
|
||||
PACKET_TYPE_NAME_LOOKUP(IceServerHeartbeat);
|
||||
PACKET_TYPE_NAME_LOOKUP(DomainServerAddedNode);
|
||||
PACKET_TYPE_NAME_LOOKUP(IceServerQuery);
|
||||
PACKET_TYPE_NAME_LOOKUP(IceServerPeerInformation);
|
||||
PACKET_TYPE_NAME_LOOKUP(UnverifiedPing);
|
||||
PACKET_TYPE_NAME_LOOKUP(UnverifiedPingReply);
|
||||
PACKET_TYPE_NAME_LOOKUP(EntityAdd);
|
||||
PACKET_TYPE_NAME_LOOKUP(EntityEdit);
|
||||
default:
|
||||
return QString("Type: ") + QString::number((int)packetType);
|
||||
}
|
||||
|
@ -143,13 +159,13 @@ QString nameForPacketType(PacketType packetType) {
|
|||
|
||||
|
||||
|
||||
QByteArray byteArrayWithUUIDPopulatedHeader(PacketType packetType, const QUuid& connectionUUID) {
|
||||
QByteArray byteArrayWithUUIDPopulatedHeader(PacketType::Value packetType, const QUuid& connectionUUID) {
|
||||
QByteArray freshByteArray(MAX_PACKET_HEADER_BYTES, 0);
|
||||
freshByteArray.resize(populatePacketHeaderWithUUID(freshByteArray, packetType, connectionUUID));
|
||||
return freshByteArray;
|
||||
}
|
||||
|
||||
int populatePacketHeaderWithUUID(QByteArray& packet, PacketType packetType, const QUuid& connectionUUID) {
|
||||
int populatePacketHeaderWithUUID(QByteArray& packet, PacketType::Value packetType, const QUuid& connectionUUID) {
|
||||
if (packet.size() < numBytesForPacketHeaderGivenPacketType(packetType)) {
|
||||
packet.resize(numBytesForPacketHeaderGivenPacketType(packetType));
|
||||
}
|
||||
|
@ -157,7 +173,7 @@ int populatePacketHeaderWithUUID(QByteArray& packet, PacketType packetType, cons
|
|||
return populatePacketHeaderWithUUID(packet.data(), packetType, connectionUUID);
|
||||
}
|
||||
|
||||
int populatePacketHeaderWithUUID(char* packet, PacketType packetType, const QUuid& connectionUUID) {
|
||||
int populatePacketHeaderWithUUID(char* packet, PacketType::Value packetType, const QUuid& connectionUUID) {
|
||||
int numTypeBytes = packArithmeticallyCodedValue(packetType, packet);
|
||||
packet[numTypeBytes] = versionForPacketType(packetType);
|
||||
|
||||
|
@ -185,31 +201,31 @@ int populatePacketHeaderWithUUID(char* packet, PacketType packetType, const QUui
|
|||
}
|
||||
|
||||
int numBytesForPacketHeader(const QByteArray& packet) {
|
||||
PacketType packetType = packetTypeForPacket(packet);
|
||||
PacketType::Value packetType = packetTypeForPacket(packet);
|
||||
return numBytesForPacketHeaderGivenPacketType(packetType);
|
||||
}
|
||||
|
||||
int numBytesForPacketHeader(const char* packet) {
|
||||
PacketType packetType = packetTypeForPacket(packet);
|
||||
PacketType::Value packetType = packetTypeForPacket(packet);
|
||||
return numBytesForPacketHeaderGivenPacketType(packetType);
|
||||
}
|
||||
|
||||
int numBytesForArithmeticCodedPacketType(PacketType packetType) {
|
||||
int numBytesForArithmeticCodedPacketType(PacketType::Value packetType) {
|
||||
return (int) ceilf((float) packetType / 255);
|
||||
}
|
||||
|
||||
int numBytesForPacketHeaderGivenPacketType(PacketType packetType) {
|
||||
int numBytesForPacketHeaderGivenPacketType(PacketType::Value packetType) {
|
||||
return numBytesForArithmeticCodedPacketType(packetType)
|
||||
+ numHashBytesForType(packetType)
|
||||
+ numSequenceNumberBytesForType(packetType)
|
||||
+ NUM_STATIC_HEADER_BYTES;
|
||||
}
|
||||
|
||||
int numHashBytesForType(PacketType packetType) {
|
||||
int numHashBytesForType(PacketType::Value packetType) {
|
||||
return (NON_VERIFIED_PACKETS.contains(packetType) ? 0 : NUM_BYTES_MD5_HASH);
|
||||
}
|
||||
|
||||
int numSequenceNumberBytesForType(PacketType packetType) {
|
||||
int numSequenceNumberBytesForType(PacketType::Value packetType) {
|
||||
return (SEQUENCE_NUMBERED_PACKETS.contains(packetType) ? sizeof(PacketSequenceNumber) : 0);
|
||||
}
|
||||
|
||||
|
@ -218,11 +234,11 @@ QUuid uuidFromPacketHeader(const QByteArray& packet) {
|
|||
NUM_BYTES_RFC4122_UUID));
|
||||
}
|
||||
|
||||
int hashOffsetForPacketType(PacketType packetType) {
|
||||
int hashOffsetForPacketType(PacketType::Value packetType) {
|
||||
return numBytesForArithmeticCodedPacketType(packetType) + NUM_STATIC_HEADER_BYTES;
|
||||
}
|
||||
|
||||
int sequenceNumberOffsetForPacketType(PacketType packetType) {
|
||||
int sequenceNumberOffsetForPacketType(PacketType::Value packetType) {
|
||||
return numBytesForPacketHeaderGivenPacketType(packetType) - sizeof(PacketSequenceNumber);
|
||||
}
|
||||
|
||||
|
@ -235,8 +251,8 @@ QByteArray hashForPacketAndConnectionUUID(const QByteArray& packet, const QUuid&
|
|||
QCryptographicHash::Md5);
|
||||
}
|
||||
|
||||
PacketSequenceNumber sequenceNumberFromHeader(const QByteArray& packet, PacketType packetType) {
|
||||
if (packetType == PacketTypeUnknown) {
|
||||
PacketSequenceNumber sequenceNumberFromHeader(const QByteArray& packet, PacketType::Value packetType) {
|
||||
if (packetType == PacketType::Unknown) {
|
||||
packetType = packetTypeForPacket(packet);
|
||||
}
|
||||
|
||||
|
@ -249,8 +265,8 @@ PacketSequenceNumber sequenceNumberFromHeader(const QByteArray& packet, PacketTy
|
|||
return result;
|
||||
}
|
||||
|
||||
void replaceHashInPacket(QByteArray& packet, const QUuid& connectionUUID, PacketType packetType) {
|
||||
if (packetType == PacketTypeUnknown) {
|
||||
void replaceHashInPacket(QByteArray& packet, const QUuid& connectionUUID, PacketType::Value packetType) {
|
||||
if (packetType == PacketType::Unknown) {
|
||||
packetType = packetTypeForPacket(packet);
|
||||
}
|
||||
|
||||
|
@ -258,8 +274,8 @@ void replaceHashInPacket(QByteArray& packet, const QUuid& connectionUUID, Packet
|
|||
hashForPacketAndConnectionUUID(packet, connectionUUID));
|
||||
}
|
||||
|
||||
void replaceSequenceNumberInPacket(QByteArray& packet, PacketSequenceNumber sequenceNumber, PacketType packetType) {
|
||||
if (packetType == PacketTypeUnknown) {
|
||||
void replaceSequenceNumberInPacket(QByteArray& packet, PacketSequenceNumber sequenceNumber, PacketType::Value packetType) {
|
||||
if (packetType == PacketType::Unknown) {
|
||||
packetType = packetTypeForPacket(packet);
|
||||
}
|
||||
|
||||
|
@ -268,8 +284,8 @@ void replaceSequenceNumberInPacket(QByteArray& packet, PacketSequenceNumber sequ
|
|||
}
|
||||
|
||||
void replaceHashAndSequenceNumberInPacket(QByteArray& packet, const QUuid& connectionUUID, PacketSequenceNumber sequenceNumber,
|
||||
PacketType packetType) {
|
||||
if (packetType == PacketTypeUnknown) {
|
||||
PacketType::Value packetType) {
|
||||
if (packetType == PacketType::Unknown) {
|
||||
packetType = packetTypeForPacket(packet);
|
||||
}
|
||||
|
||||
|
@ -277,10 +293,10 @@ void replaceHashAndSequenceNumberInPacket(QByteArray& packet, const QUuid& conne
|
|||
replaceSequenceNumberInPacket(packet, sequenceNumber, packetType);
|
||||
}
|
||||
|
||||
PacketType packetTypeForPacket(const QByteArray& packet) {
|
||||
return (PacketType) arithmeticCodingValueFromBuffer(packet.data());
|
||||
PacketType::Value packetTypeForPacket(const QByteArray& packet) {
|
||||
return (PacketType::Value) arithmeticCodingValueFromBuffer(packet.data());
|
||||
}
|
||||
|
||||
PacketType packetTypeForPacket(const char* packet) {
|
||||
return (PacketType) arithmeticCodingValueFromBuffer(packet);
|
||||
PacketType::Value packetTypeForPacket(const char* packet) {
|
||||
return (PacketType::Value) arithmeticCodingValueFromBuffer(packet);
|
||||
}
|
||||
|
|
|
@ -89,67 +89,55 @@ typedef char PacketVersion;
|
|||
typedef uint16_t PacketSequenceNumber;
|
||||
const PacketSequenceNumber DEFAULT_SEQUENCE_NUMBER = 0;
|
||||
|
||||
typedef std::map<PacketType, PacketSequenceNumber> PacketTypeSequenceMap;
|
||||
typedef std::map<PacketType::Value, PacketSequenceNumber> PacketTypeSequenceMap;
|
||||
|
||||
const QSet<PacketType> NON_VERIFIED_PACKETS = QSet<PacketType>()
|
||||
<< PacketTypeDomainServerRequireDTLS << PacketTypeDomainConnectRequest
|
||||
<< PacketTypeDomainList << PacketTypeDomainListRequest << PacketTypeDomainConnectionDenied
|
||||
<< PacketTypeCreateAssignment << PacketTypeRequestAssignment << PacketTypeStunResponse
|
||||
<< PacketTypeNodeJsonStats << PacketTypeEntityQuery
|
||||
<< PacketTypeOctreeDataNack << PacketTypeEntityEditNack
|
||||
<< PacketTypeIceServerHeartbeat << PacketTypeIceServerPeerInformation
|
||||
<< PacketTypeIceServerQuery << PacketTypeUnverifiedPing
|
||||
<< PacketTypeUnverifiedPingReply << PacketTypeStopNode
|
||||
<< PacketTypeDomainServerPathQuery << PacketTypeDomainServerPathResponse
|
||||
<< PacketTypeDomainServerAddedNode;
|
||||
|
||||
const QSet<PacketType> SEQUENCE_NUMBERED_PACKETS = QSet<PacketType>()
|
||||
<< PacketTypeAvatarData;
|
||||
extern const QSet<PacketType::Value> NON_VERIFIED_PACKETS;
|
||||
extern const QSet<PacketType::Value> SEQUENCE_NUMBERED_PACKETS;
|
||||
|
||||
const int NUM_BYTES_MD5_HASH = 16;
|
||||
const int NUM_STATIC_HEADER_BYTES = sizeof(PacketVersion) + NUM_BYTES_RFC4122_UUID;
|
||||
const int MAX_PACKET_HEADER_BYTES = sizeof(PacketType) + NUM_BYTES_MD5_HASH + NUM_STATIC_HEADER_BYTES;
|
||||
const int MAX_PACKET_HEADER_BYTES = sizeof(PacketType::Value) + NUM_BYTES_MD5_HASH + NUM_STATIC_HEADER_BYTES;
|
||||
|
||||
PacketType packetTypeForPacket(const QByteArray& packet);
|
||||
PacketType packetTypeForPacket(const char* packet);
|
||||
PacketType::Value packetTypeForPacket(const QByteArray& packet);
|
||||
PacketType::Value packetTypeForPacket(const char* packet);
|
||||
|
||||
PacketVersion versionForPacketType(PacketType packetType);
|
||||
QString nameForPacketType(PacketType packetType);
|
||||
PacketVersion versionForPacketType(PacketType::Value packetType);
|
||||
QString nameForPacketType(PacketType::Value packetType);
|
||||
|
||||
const QUuid nullUUID = QUuid();
|
||||
|
||||
QByteArray byteArrayWithUUIDPopulatedHeader(PacketType packetType, const QUuid& connectionUUID);
|
||||
int populatePacketHeaderWithUUID(QByteArray& packet, PacketType packetType, const QUuid& connectionUUID);
|
||||
int populatePacketHeaderWithUUID(char* packet, PacketType packetType, const QUuid& connectionUUID);
|
||||
QByteArray byteArrayWithUUIDPopulatedHeader(PacketType::Value packetType, const QUuid& connectionUUID);
|
||||
int populatePacketHeaderWithUUID(QByteArray& packet, PacketType::Value packetType, const QUuid& connectionUUID);
|
||||
int populatePacketHeaderWithUUID(char* packet, PacketType::Value packetType, const QUuid& connectionUUID);
|
||||
|
||||
int numHashBytesForType(PacketType packetType);
|
||||
int numSequenceNumberBytesForType(PacketType packetType);
|
||||
int numHashBytesForType(PacketType::Value packetType);
|
||||
int numSequenceNumberBytesForType(PacketType::Value packetType);
|
||||
|
||||
int numBytesForPacketHeader(const QByteArray& packet);
|
||||
int numBytesForPacketHeader(const char* packet);
|
||||
int numBytesForArithmeticCodedPacketType(PacketType packetType);
|
||||
int numBytesForPacketHeaderGivenPacketType(PacketType packetType);
|
||||
int numBytesForArithmeticCodedPacketType(PacketType::Value packetType);
|
||||
int numBytesForPacketHeaderGivenPacketType(PacketType::Value packetType);
|
||||
|
||||
QUuid uuidFromPacketHeader(const QByteArray& packet);
|
||||
|
||||
int hashOffsetForPacketType(PacketType packetType);
|
||||
int sequenceNumberOffsetForPacketType(PacketType packetType);
|
||||
int hashOffsetForPacketType(PacketType::Value packetType);
|
||||
int sequenceNumberOffsetForPacketType(PacketType::Value packetType);
|
||||
|
||||
QByteArray hashFromPacketHeader(const QByteArray& packet);
|
||||
QByteArray hashForPacketAndConnectionUUID(const QByteArray& packet, const QUuid& connectionUUID);
|
||||
|
||||
// NOTE: The following four methods accept a PacketType which defaults to PacketTypeUnknown.
|
||||
// NOTE: The following four methods accept a PacketType::Value which defaults to PacketType::Unknown.
|
||||
// If the caller has already looked at the packet type and can provide it then the methods below won't have to look it up.
|
||||
|
||||
PacketSequenceNumber sequenceNumberFromHeader(const QByteArray& packet, PacketType packetType = PacketTypeUnknown);
|
||||
PacketSequenceNumber sequenceNumberFromHeader(const QByteArray& packet, PacketType::Value packetType = PacketType::Unknown);
|
||||
|
||||
void replaceHashInPacket(QByteArray& packet, const QUuid& connectionUUID, PacketType packetType = PacketTypeUnknown);
|
||||
void replaceHashInPacket(QByteArray& packet, const QUuid& connectionUUID, PacketType::Value packetType = PacketType::Unknown);
|
||||
|
||||
void replaceSequenceNumberInPacket(QByteArray& packet, PacketSequenceNumber sequenceNumber,
|
||||
PacketType packetType = PacketTypeUnknown);
|
||||
PacketType::Value packetType = PacketType::Unknown);
|
||||
|
||||
void replaceHashAndSequenceNumberInPacket(QByteArray& packet, const QUuid& connectionUUID, PacketSequenceNumber sequenceNumber,
|
||||
PacketType packetType = PacketTypeUnknown);
|
||||
PacketType::Value packetType = PacketType::Unknown);
|
||||
|
||||
int arithmeticCodingValueFromBuffer(const char* checkValue);
|
||||
int numBytesArithmeticCodingFromBuffer(const char* checkValue);
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
qint64 satoshiCost = 0, const QUuid nodeUUID = QUuid());
|
||||
|
||||
QUuid _nodeUUID;
|
||||
PacketType _currentType;
|
||||
PacketType::Value _currentType;
|
||||
unsigned char _currentBuffer[MAX_PACKET_SIZE];
|
||||
size_t _currentSize;
|
||||
qint64 _satoshiCost;
|
||||
|
|
|
@ -1936,7 +1936,7 @@ bool Octree::readSVOFromStream(unsigned long streamLength, QDataStream& inputStr
|
|||
|
||||
bool wantImportProgress = true;
|
||||
|
||||
PacketType expectedType = expectedDataPacketType();
|
||||
PacketType::Value expectedType = expectedDataPacketType();
|
||||
PacketVersion expectedVersion = versionForPacketType(expectedType);
|
||||
bool hasBufferBreaks = versionHasSVOfileBreaks(expectedVersion);
|
||||
|
||||
|
@ -1954,7 +1954,7 @@ bool Octree::readSVOFromStream(unsigned long streamLength, QDataStream& inputStr
|
|||
unsigned long dataLength = HEADER_LENGTH;
|
||||
|
||||
// if so, read the first byte of the file and see if it matches the expected version code
|
||||
PacketType gotType;
|
||||
PacketType::Value gotType;
|
||||
memcpy(&gotType, dataAt, sizeof(gotType));
|
||||
|
||||
dataAt += sizeof(expectedType);
|
||||
|
@ -2097,7 +2097,7 @@ void Octree::writeToJSONFile(const char* fileName, OctreeElement* element) {
|
|||
}
|
||||
|
||||
// include the "bitstream" version
|
||||
PacketType expectedType = expectedDataPacketType();
|
||||
PacketType::Value expectedType = expectedDataPacketType();
|
||||
PacketVersion expectedVersion = versionForPacketType(expectedType);
|
||||
entityDescription["Version"] = (int) expectedVersion;
|
||||
|
||||
|
@ -2118,7 +2118,7 @@ void Octree::writeToSVOFile(const char* fileName, OctreeElement* element) {
|
|||
if(file.is_open()) {
|
||||
qCDebug(octree, "Saving binary SVO to file %s...", fileName);
|
||||
|
||||
PacketType expectedType = expectedDataPacketType();
|
||||
PacketType::Value expectedType = expectedDataPacketType();
|
||||
PacketVersion expectedVersion = versionForPacketType(expectedType);
|
||||
bool hasBufferBreaks = versionHasSVOfileBreaks(expectedVersion);
|
||||
|
||||
|
|
|
@ -226,7 +226,7 @@ public:
|
|||
// These methods will allow the OctreeServer to send your tree inbound edit packets of your
|
||||
// own definition. Implement these to allow your octree based server to support editing
|
||||
virtual bool getWantSVOfileVersions() const { return false; }
|
||||
virtual PacketType expectedDataPacketType() const { return PacketTypeUnknown; }
|
||||
virtual PacketType::Value expectedDataPacketType() const { return PacketTypeUnknown; }
|
||||
virtual bool canProcessVersion(PacketVersion thisVersion) const {
|
||||
return thisVersion == versionForPacketType(expectedDataPacketType()); }
|
||||
virtual PacketVersion expectedVersion() const { return versionForPacketType(expectedDataPacketType()); }
|
||||
|
|
|
@ -327,7 +327,7 @@ void OctreeEditPacketSender::releaseQueuedPacket(EditPacketBuffer& packetBuffer)
|
|||
_releaseQueuedPacketMutex.unlock();
|
||||
}
|
||||
|
||||
void OctreeEditPacketSender::initializePacket(EditPacketBuffer& packetBuffer, PacketType type, int nodeClockSkew) {
|
||||
void OctreeEditPacketSender::initializePacket(EditPacketBuffer& packetBuffer, PacketType::Value type, int nodeClockSkew) {
|
||||
packetBuffer._currentSize =
|
||||
DependencyManager::get<NodeList>()->populatePacketHeader(reinterpret_cast<char*>(&packetBuffer._currentBuffer[0]), type);
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ protected:
|
|||
void queuePacketToNode(const QUuid& nodeID, unsigned char* buffer, size_t length, qint64 satoshiCost = 0);
|
||||
void queuePendingPacketToNodes(PacketType type, unsigned char* buffer, size_t length, qint64 satoshiCost = 0);
|
||||
void queuePacketToNodes(unsigned char* buffer, size_t length, qint64 satoshiCost = 0);
|
||||
void initializePacket(EditPacketBuffer& packetBuffer, PacketType type, int nodeClockSkew);
|
||||
void initializePacket(EditPacketBuffer& packetBuffer, PacketType::Value type, int nodeClockSkew);
|
||||
void releaseQueuedPacket(EditPacketBuffer& packetBuffer); // releases specific queued packet
|
||||
|
||||
void processPreServerExistsPackets();
|
||||
|
|
|
@ -33,7 +33,7 @@ void OctreeHeadlessViewer::init() {
|
|||
|
||||
void OctreeHeadlessViewer::queryOctree() {
|
||||
char serverType = getMyNodeType();
|
||||
PacketType packetType = getMyQueryMessageType();
|
||||
PacketType::Value packetType = getMyQueryMessageType();
|
||||
NodeToJurisdictionMap& jurisdictions = *_jurisdictionListener->getJurisdictions();
|
||||
|
||||
bool wantExtraDebugging = false;
|
||||
|
|
|
@ -42,7 +42,7 @@ typedef quint64 OCTREE_PACKET_SENT_TIME;
|
|||
typedef uint16_t OCTREE_PACKET_INTERNAL_SECTION_SIZE;
|
||||
const int MAX_OCTREE_PACKET_SIZE = MAX_PACKET_SIZE;
|
||||
|
||||
// this is overly conservative - sizeof(PacketType) is 8 bytes but a packed PacketType could be as small as one byte
|
||||
// this is overly conservative - sizeof(PacketType) is 8 bytes but a packed PacketType::Value could be as small as one byte
|
||||
const unsigned int OCTREE_PACKET_EXTRA_HEADERS_SIZE = sizeof(OCTREE_PACKET_FLAGS)
|
||||
+ sizeof(OCTREE_PACKET_SEQUENCE) + sizeof(OCTREE_PACKET_SENT_TIME);
|
||||
|
||||
|
|
|
@ -62,10 +62,10 @@ void OctreeRenderer::processDatagram(const QByteArray& dataByteArray, const Shar
|
|||
PerformanceWarning warn(showTimingDetails, "OctreeRenderer::processDatagram()",showTimingDetails);
|
||||
|
||||
unsigned int packetLength = dataByteArray.size();
|
||||
PacketType command = packetTypeForPacket(dataByteArray);
|
||||
PacketType::Value command = packetTypeForPacket(dataByteArray);
|
||||
unsigned int numBytesPacketHeader = numBytesForPacketHeader(dataByteArray);
|
||||
QUuid sourceUUID = uuidFromPacketHeader(dataByteArray);
|
||||
PacketType expectedType = getExpectedPacketType();
|
||||
PacketType::Value expectedType = getExpectedPacketType();
|
||||
// packetVersion is the second byte
|
||||
PacketVersion packetVersion = dataByteArray[1];
|
||||
|
||||
|
|
|
@ -36,8 +36,8 @@ public:
|
|||
virtual ~OctreeRenderer();
|
||||
|
||||
virtual char getMyNodeType() const = 0;
|
||||
virtual PacketType getMyQueryMessageType() const = 0;
|
||||
virtual PacketType getExpectedPacketType() const = 0;
|
||||
virtual PacketType::Value getMyQueryMessageType() const = 0;
|
||||
virtual PacketType::Value getExpectedPacketType() const = 0;
|
||||
virtual void renderElement(OctreeElement* element, RenderArgs* args) = 0;
|
||||
virtual float getSizeScale() const { return DEFAULT_OCTREE_SIZE_SCALE; }
|
||||
virtual int getBoundaryLevelAdjust() const { return 0; }
|
||||
|
|
Loading…
Reference in a new issue