replace PacketType declarations with PacketType::Value

This commit is contained in:
Stephen Birarda 2015-07-02 16:38:52 -07:00
parent 5ed332ea2c
commit 0d64e82fe2
36 changed files with 57 additions and 57 deletions

View file

@ -56,7 +56,7 @@ void Agent::readPendingDatagrams() {
while (readAvailableDatagram(receivedPacket, senderSockAddr)) { while (readAvailableDatagram(receivedPacket, senderSockAddr)) {
if (nodeList->packetVersionAndHashMatch(receivedPacket)) { if (nodeList->packetVersionAndHashMatch(receivedPacket)) {
PacketType datagramPacketType = packetTypeForPacket(receivedPacket); PacketType::Value datagramPacketType = packetTypeForPacket(receivedPacket);
if (datagramPacketType == PacketTypeJurisdiction) { if (datagramPacketType == PacketTypeJurisdiction) {
int headerBytes = numBytesForPacketHeader(receivedPacket); int headerBytes = numBytesForPacketHeader(receivedPacket);

View file

@ -535,7 +535,7 @@ void AudioMixer::readPendingDatagram(const QByteArray& receivedPacket, const Hif
if (nodeList->packetVersionAndHashMatch(receivedPacket)) { if (nodeList->packetVersionAndHashMatch(receivedPacket)) {
// pull any new audio data from nodes off of the network stack // pull any new audio data from nodes off of the network stack
PacketType mixerPacketType = packetTypeForPacket(receivedPacket); PacketType::Value mixerPacketType = packetTypeForPacket(receivedPacket);
if (mixerPacketType == PacketTypeMicrophoneAudioNoEcho if (mixerPacketType == PacketTypeMicrophoneAudioNoEcho
|| mixerPacketType == PacketTypeMicrophoneAudioWithEcho || mixerPacketType == PacketTypeMicrophoneAudioWithEcho
|| mixerPacketType == PacketTypeInjectAudio || mixerPacketType == PacketTypeInjectAudio

View file

@ -50,7 +50,7 @@ AvatarAudioStream* AudioMixerClientData::getAvatarAudioStream() const {
} }
int AudioMixerClientData::parseData(const QByteArray& packet) { int AudioMixerClientData::parseData(const QByteArray& packet) {
PacketType packetType = packetTypeForPacket(packet); PacketType::Value packetType = packetTypeForPacket(packet);
if (packetType == PacketTypeAudioStreamStats) { if (packetType == PacketTypeAudioStreamStats) {
const char* dataAt = packet.data(); const char* dataAt = packet.data();

View file

@ -22,7 +22,7 @@ public:
OctreeQueryNode(), OctreeQueryNode(),
_lastDeletedEntitiesSentAt(0) { } _lastDeletedEntitiesSentAt(0) { }
virtual PacketType getMyPacketType() const { return PacketTypeEntityData; } virtual PacketType::Value getMyPacketType() const { return PacketTypeEntityData; }
quint64 getLastDeletedEntitiesSentAt() const { return _lastDeletedEntitiesSentAt; } quint64 getLastDeletedEntitiesSentAt() const { return _lastDeletedEntitiesSentAt; }
void setLastDeletedEntitiesSentAt(quint64 sentAt) { _lastDeletedEntitiesSentAt = sentAt; } void setLastDeletedEntitiesSentAt(quint64 sentAt) { _lastDeletedEntitiesSentAt = sentAt; }

View file

@ -28,11 +28,11 @@ public:
// Subclasses must implement these methods // Subclasses must implement these methods
virtual OctreeQueryNode* createOctreeQueryNode(); virtual OctreeQueryNode* createOctreeQueryNode();
virtual char getMyNodeType() const { return NodeType::EntityServer; } 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* getMyServerName() const { return MODEL_SERVER_NAME; }
virtual const char* getMyLoggingServerTargetName() const { return MODEL_SERVER_LOGGING_TARGET_NAME; } virtual const char* getMyLoggingServerTargetName() const { return MODEL_SERVER_LOGGING_TARGET_NAME; }
virtual const char* getMyDefaultPersistFilename() const { return LOCAL_MODELS_PERSIST_FILE; } 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"); } virtual QString getMyDomainSettingsKey() const { return QString("entity_server_settings"); }
// subclass may implement these method // subclass may implement these method

View file

@ -90,7 +90,7 @@ void OctreeInboundPacketProcessor::processPacket(const SharedNodePointer& sendin
// Ask our tree subclass if it can handle the incoming packet... // 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)) { if (_myServer->getOctree()->handlesEditPacketType(packetType)) {
PerformanceWarning warn(debugProcessPacket, "processPacket KNOWN TYPE",debugProcessPacket); PerformanceWarning warn(debugProcessPacket, "processPacket KNOWN TYPE",debugProcessPacket);
_receivedPacketCount++; _receivedPacketCount++;

View file

@ -35,7 +35,7 @@ public:
virtual ~OctreeQueryNode(); virtual ~OctreeQueryNode();
void init(); // called after creation to set up some virtual items 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 void resetOctreePacket(); // resets octree packet to after "V" header
@ -155,7 +155,7 @@ private:
quint64 _lastRootTimestamp; quint64 _lastRootTimestamp;
PacketType _myPacketType; PacketType::Value _myPacketType;
bool _isShuttingDown; bool _isShuttingDown;
SentPacketHistory _sentPacketHistory; SentPacketHistory _sentPacketHistory;

View file

@ -862,7 +862,7 @@ void OctreeServer::readPendingDatagram(const QByteArray& receivedPacket, const H
if (!_isShuttingDown) { if (!_isShuttingDown) {
if (nodeList->packetVersionAndHashMatch(receivedPacket)) { if (nodeList->packetVersionAndHashMatch(receivedPacket)) {
PacketType packetType = packetTypeForPacket(receivedPacket); PacketType::Value packetType = packetTypeForPacket(receivedPacket);
SharedNodePointer matchingNode = nodeList->sendingNodeForPacket(receivedPacket); SharedNodePointer matchingNode = nodeList->sendingNodeForPacket(receivedPacket);
if (packetType == getMyQueryMessageType()) { if (packetType == getMyQueryMessageType()) {
// If we got a query packet, then we're talking to an agent, and we // If we got a query packet, then we're talking to an agent, and we

View file

@ -63,11 +63,11 @@ public:
// Subclasses must implement these methods // Subclasses must implement these methods
virtual OctreeQueryNode* createOctreeQueryNode() = 0; virtual OctreeQueryNode* createOctreeQueryNode() = 0;
virtual char getMyNodeType() const = 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* getMyServerName() const = 0;
virtual const char* getMyLoggingServerTargetName() const = 0; virtual const char* getMyLoggingServerTargetName() const = 0;
virtual const char* getMyDefaultPersistFilename() 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"); } virtual QString getMyDomainSettingsKey() const { return QString("octree_server_settings"); }
// subclass may implement these method // subclass may implement these method

View file

@ -43,7 +43,7 @@ void OctreeServerDatagramProcessor::readPendingDatagrams() {
_nodeSocket.readDatagram(incomingPacket.data(), incomingPacket.size(), _nodeSocket.readDatagram(incomingPacket.data(), incomingPacket.size(),
senderSockAddr.getAddressPointer(), senderSockAddr.getPortPointer()); senderSockAddr.getAddressPointer(), senderSockAddr.getPortPointer());
PacketType packetType = packetTypeForPacket(incomingPacket); PacketType::Value packetType = packetTypeForPacket(incomingPacket);
if (packetType == PacketTypePing) { if (packetType == PacketTypePing) {
DependencyManager::get<NodeList>()->processNodeData(senderSockAddr, incomingPacket); DependencyManager::get<NodeList>()->processNodeData(senderSockAddr, incomingPacket);
return; // don't emit return; // don't emit

View file

@ -1390,7 +1390,7 @@ void DomainServer::processDatagram(const QByteArray& receivedPacket, const HifiS
auto nodeList = DependencyManager::get<LimitedNodeList>(); auto nodeList = DependencyManager::get<LimitedNodeList>();
if (nodeList->packetVersionAndHashMatch(receivedPacket)) { if (nodeList->packetVersionAndHashMatch(receivedPacket)) {
PacketType requestType = packetTypeForPacket(receivedPacket); PacketType::Value requestType = packetTypeForPacket(receivedPacket);
switch (requestType) { switch (requestType) {
case PacketTypeDomainConnectRequest: case PacketTypeDomainConnectRequest:
handleConnectRequest(receivedPacket, senderSockAddr); handleConnectRequest(receivedPacket, senderSockAddr);

View file

@ -54,7 +54,7 @@ void IceServer::processDatagrams() {
_serverSocket.readDatagram(incomingPacket.data(), incomingPacket.size(), _serverSocket.readDatagram(incomingPacket.data(), incomingPacket.size(),
sendingSockAddr.getAddressPointer(), sendingSockAddr.getPortPointer()); sendingSockAddr.getAddressPointer(), sendingSockAddr.getPortPointer());
PacketType packetType = packetTypeForPacket(incomingPacket); PacketType::Value packetType = packetTypeForPacket(incomingPacket);
if (packetType == PacketTypeIceServerHeartbeat) { if (packetType == PacketTypeIceServerHeartbeat) {
SharedNetworkPeer peer = addOrUpdateHeartbeatingPeer(incomingPacket); SharedNetworkPeer peer = addOrUpdateHeartbeatingPeer(incomingPacket);

View file

@ -2729,7 +2729,7 @@ int Application::sendNackPackets() {
return packetsSent; 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(); //qCDebug(interfaceapp) << ">>> inside... queryOctree()... _viewFrustum.getFieldOfView()=" << _viewFrustum.getFieldOfView();
bool wantExtraDebugging = getLogger()->extraDebugging(); bool wantExtraDebugging = getLogger()->extraDebugging();

View file

@ -511,7 +511,7 @@ private:
void renderLookatIndicator(glm::vec3 pointOfInterest); 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); void loadViewFrustum(Camera& camera, ViewFrustum& viewFrustum);
glm::vec3 getSunDirection(); glm::vec3 getSunDirection();

View file

@ -52,7 +52,7 @@ void DatagramProcessor::processDatagrams() {
if (nodeList->packetVersionAndHashMatch(incomingPacket)) { 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 // only process this packet if we have a match on the packet version
switch (incomingType) { switch (incomingType) {
case PacketTypeAudioEnvironment: case PacketTypeAudioEnvironment:

View file

@ -33,7 +33,7 @@ void OctreePacketProcessor::processPacket(const SharedNodePointer& sendingNode,
bool wasStatsPacket = false; bool wasStatsPacket = false;
PacketType voxelPacketType = packetTypeForPacket(mutablePacket); PacketType::Value voxelPacketType = packetTypeForPacket(mutablePacket);
// note: PacketType_OCTREE_STATS can have PacketType_VOXEL_DATA // note: PacketType_OCTREE_STATS can have PacketType_VOXEL_DATA
// immediately following them inside the same packet. So, we process the PacketType_OCTREE_STATS first // immediately following them inside the same packet. So, we process the PacketType_OCTREE_STATS first

View file

@ -844,7 +844,7 @@ void AudioClient::handleAudioInput() {
glm::quat headOrientation = _orientationGetter(); glm::quat headOrientation = _orientationGetter();
quint8 isStereo = _isStereoInput ? 1 : 0; quint8 isStereo = _isStereoInput ? 1 : 0;
PacketType packetType; PacketType::Value packetType;
if (_lastInputLoudness == 0) { if (_lastInputLoudness == 0) {
packetType = PacketTypeSilentAudioFrame; packetType = PacketTypeSilentAudioFrame;
} else { } else {

View file

@ -98,7 +98,7 @@ void InboundAudioStream::perSecondCallbackForUpdatingStats() {
int InboundAudioStream::parseData(const QByteArray& packet) { int InboundAudioStream::parseData(const QByteArray& packet) {
PacketType packetType = packetTypeForPacket(packet); PacketType::Value packetType = packetTypeForPacket(packet);
QUuid senderUUID = uuidFromPacketHeader(packet); QUuid senderUUID = uuidFromPacketHeader(packet);
// parse header // parse header

View file

@ -43,8 +43,8 @@ public:
virtual ~EntityTreeRenderer(); virtual ~EntityTreeRenderer();
virtual char getMyNodeType() const { return NodeType::EntityServer; } virtual char getMyNodeType() const { return NodeType::EntityServer; }
virtual PacketType getMyQueryMessageType() const { return PacketTypeEntityQuery; } virtual PacketType::Value getMyQueryMessageType() const { return PacketTypeEntityQuery; }
virtual PacketType getExpectedPacketType() const { return PacketTypeEntityData; } virtual PacketType::Value getExpectedPacketType() const { return PacketTypeEntityData; }
virtual void renderElement(OctreeElement* element, RenderArgs* args); virtual void renderElement(OctreeElement* element, RenderArgs* args);
virtual float getSizeScale() const; virtual float getSizeScale() const;
virtual int getBoundaryLevelAdjust() const; virtual int getBoundaryLevelAdjust() const;

View file

@ -62,7 +62,7 @@ public:
// These methods will allow the OctreeServer to send your tree inbound edit packets of your // 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 // own definition. Implement these to allow your octree based server to support editing
virtual bool getWantSVOfileVersions() const { return true; } 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 virtual bool canProcessVersion(PacketVersion thisVersion) const
{ return thisVersion >= VERSION_ENTITIES_USE_METERS_AND_RADIANS; } { return thisVersion >= VERSION_ENTITIES_USE_METERS_AND_RADIANS; }
virtual bool handlesEditPacketType(PacketType packetType) const; virtual bool handlesEditPacketType(PacketType packetType) const;

View file

@ -31,8 +31,8 @@ public:
virtual ~EntityTreeHeadlessViewer(); virtual ~EntityTreeHeadlessViewer();
virtual char getMyNodeType() const { return NodeType::EntityServer; } virtual char getMyNodeType() const { return NodeType::EntityServer; }
virtual PacketType getMyQueryMessageType() const { return PacketTypeEntityQuery; } virtual PacketType::Value getMyQueryMessageType() const { return PacketTypeEntityQuery; }
virtual PacketType getExpectedPacketType() const { return PacketTypeEntityData; } virtual PacketType::Value getExpectedPacketType() const { return PacketTypeEntityData; }
void update(); void update();

View file

@ -66,7 +66,7 @@ Assignment::Assignment(const QByteArray& packet) :
_payload(), _payload(),
_walletUUID() _walletUUID()
{ {
PacketType packetType = packetTypeForPacket(packet); PacketType::Value packetType = packetTypeForPacket(packet);
if (packetType == PacketTypeRequestAssignment) { if (packetType == PacketTypeRequestAssignment) {
_command = Assignment::RequestCommand; _command = Assignment::RequestCommand;

View file

@ -164,12 +164,12 @@ void LimitedNodeList::changeSocketBufferSizes(int numBytes) {
} }
bool LimitedNodeList::packetVersionAndHashMatch(const QByteArray& packet) { bool LimitedNodeList::packetVersionAndHashMatch(const QByteArray& packet) {
PacketType checkType = packetTypeForPacket(packet); PacketType::Value checkType = packetTypeForPacket(packet);
int numPacketTypeBytes = numBytesArithmeticCodingFromBuffer(packet.data()); int numPacketTypeBytes = numBytesArithmeticCodingFromBuffer(packet.data());
if (packet[numPacketTypeBytes] != versionForPacketType(checkType) if (packet[numPacketTypeBytes] != versionForPacketType(checkType)
&& checkType != PacketTypeStunResponse) { && checkType != PacketTypeStunResponse) {
PacketType mismatchType = packetTypeForPacket(packet); PacketType::Value mismatchType = packetTypeForPacket(packet);
static QMultiMap<QUuid, PacketType> versionDebugSuppressMap; static QMultiMap<QUuid, PacketType> versionDebugSuppressMap;
@ -254,7 +254,7 @@ qint64 LimitedNodeList::writeDatagram(const QByteArray& datagram,
const SharedNodePointer& destinationNode, const SharedNodePointer& destinationNode,
const HifiSockAddr& overridenSockAddr) { const HifiSockAddr& overridenSockAddr) {
if (destinationNode) { if (destinationNode) {
PacketType 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);
@ -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 // optionally peform sequence number replacement in the header
if (SEQUENCE_NUMBERED_PACKETS.contains(packetType)) { 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); 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 // Thanks to std::map and std::unordered_map this line either default constructs the
// PacketTypeSequenceMap and the PacketSequenceNumber or returns the existing value. // PacketTypeSequenceMap and the PacketSequenceNumber or returns the existing value.
// We use the postfix increment so that the stored value is incremented and the next // 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 // if this was a sequence numbered packet we should store the last seq number for
// a packet of this type for this node // a packet of this type for this node
PacketType packetType = packetTypeForPacket(packet); PacketType::Value packetType = packetTypeForPacket(packet);
if (SEQUENCE_NUMBERED_PACKETS.contains(packetType)) { if (SEQUENCE_NUMBERED_PACKETS.contains(packetType)) {
matchingNode->setLastSequenceNumberForPacketType(sequenceNumberFromHeader(packet, packetType), packetType); matchingNode->setLastSequenceNumberForPacketType(sequenceNumberFromHeader(packet, packetType), packetType);
} }
@ -546,7 +546,7 @@ QByteArray LimitedNodeList::constructPingReplyPacket(const QByteArray& pingPacke
quint64 timeFromOriginalPing; quint64 timeFromOriginalPing;
pingPacketStream >> timeFromOriginalPing; pingPacketStream >> timeFromOriginalPing;
PacketType replyType = (packetTypeForPacket(pingPacket) == PacketTypePing) PacketType::Value replyType = (packetTypeForPacket(pingPacket) == PacketTypePing)
? PacketTypePingReply : PacketTypeUnverifiedPingReply; ? PacketTypePingReply : PacketTypeUnverifiedPingReply;
QUuid packetUUID = packetHeaderID.isNull() ? _sessionUUID : packetHeaderID; QUuid packetUUID = packetHeaderID.isNull() ? _sessionUUID : packetHeaderID;

View file

@ -120,9 +120,9 @@ public:
// QByteArray byteArrayWithPopulatedHeader(PacketType packetType) // QByteArray byteArrayWithPopulatedHeader(PacketType packetType)
// { return byteArrayWithUUIDPopulatedHeader(packetType, _sessionUUID); } // { return byteArrayWithUUIDPopulatedHeader(packetType, _sessionUUID); }
// int populatePacketHeader(QByteArray& packet, PacketType packetType) // int populatePacketHeader(QByteArray& packet, PacketType::Value packetType)
// { return populatePacketHeaderWithUUID(packet, packetType, _sessionUUID); } // { return populatePacketHeaderWithUUID(packet, packetType, _sessionUUID); }
// int populatePacketHeader(char* packet, PacketType packetType) // int populatePacketHeader(char* packet, PacketType::Value packetType)
// { return populatePacketHeaderWithUUID(packet, packetType, _sessionUUID); } // { return populatePacketHeaderWithUUID(packet, packetType, _sessionUUID); }
qint64 readDatagram(QByteArray& incomingPacket, QHostAddress* address, quint16 * port); qint64 readDatagram(QByteArray& incomingPacket, QHostAddress* address, quint16 * port);
@ -266,7 +266,7 @@ protected:
qint64 writeDatagram(const QByteArray& datagram, const HifiSockAddr& destinationSockAddr); 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); void changeSocketBufferSizes(int numBytes);

View file

@ -65,7 +65,7 @@ public:
void setCanRez(bool canRez) { _canRez = canRez; } void setCanRez(bool canRez) { _canRez = canRez; }
bool getCanRez() { return _canRez; } bool getCanRez() { return _canRez; }
void setLastSequenceNumberForPacketType(PacketSequenceNumber sequenceNumber, PacketType packetType) void setLastSequenceNumberForPacketType(PacketSequenceNumber sequenceNumber, PacketType::Value packetType)
{ _lastSequenceNumbers[packetType] = sequenceNumber; } { _lastSequenceNumbers[packetType] = sequenceNumber; }
PacketSequenceNumber getLastSequenceNumberForPacketType(PacketType packetType) const; PacketSequenceNumber getLastSequenceNumberForPacketType(PacketType packetType) const;

View file

@ -173,7 +173,7 @@ void NodeList::timePingReply(const QByteArray& packet, const SharedNodePointer&
} }
void NodeList::processNodeData(const HifiSockAddr& senderSockAddr, const QByteArray& packet) { void NodeList::processNodeData(const HifiSockAddr& senderSockAddr, const QByteArray& packet) {
PacketType packetType = packetTypeForPacket(packet); PacketType::Value packetType = packetTypeForPacket(packet);
switch (packetType) { switch (packetType) {
case PacketTypeDomainList: case PacketTypeDomainList:
case PacketTypeDomainServerAddedNode: { case PacketTypeDomainServerAddedNode: {
@ -309,7 +309,7 @@ void NodeList::sendDomainServerCheckIn() {
} else if (!_domainHandler.getIP().isNull()) { } else if (!_domainHandler.getIP().isNull()) {
bool isUsingDTLS = false; bool isUsingDTLS = false;
PacketType domainPacketType = !_domainHandler.isConnected() PacketType::Value domainPacketType = !_domainHandler.isConnected()
? PacketTypeDomainConnectRequest : PacketTypeDomainListRequest; ? PacketTypeDomainConnectRequest : PacketTypeDomainListRequest;
if (!_domainHandler.isConnected()) { if (!_domainHandler.isConnected()) {
@ -600,7 +600,7 @@ void NodeList::parseNodeFromPacketStream(QDataStream& packetStream) {
void NodeList::sendAssignment(Assignment& assignment) { void NodeList::sendAssignment(Assignment& assignment) {
PacketType assignmentPacketType = assignment.getCommand() == Assignment::CreateCommand PacketType::Value assignmentPacketType = assignment.getCommand() == Assignment::CreateCommand
? PacketTypeCreateAssignment ? PacketTypeCreateAssignment
: PacketTypeRequestAssignment; : PacketTypeRequestAssignment;

View file

@ -26,7 +26,7 @@
// NOTE: if adding a new packet packetType, you can replace one marked usable or add at the end // NOTE: if adding a new packet packetType, you can replace one marked usable or add at the end
// NOTE: if you want the name of the packet packetType to be available for debugging or logging, update nameForPacketType() as well // NOTE: if you want the name of the packet packetType to be available for debugging or logging, update nameForPacketType() as well
namespace PacketType { namespace PacketType::Value {
enum Value { enum Value {
Unknown, // 0 Unknown, // 0
StunResponse, StunResponse,
@ -126,7 +126,7 @@ int sequenceNumberOffsetForPacketType(PacketType::Value packetType);
QByteArray hashFromPacketHeader(const QByteArray& packet); QByteArray hashFromPacketHeader(const QByteArray& packet);
QByteArray hashForPacketAndConnectionUUID(const QByteArray& packet, const QUuid& connectionUUID); QByteArray hashForPacketAndConnectionUUID(const QByteArray& packet, const QUuid& connectionUUID);
// NOTE: The following four methods accept a PacketType which defaults to PacketType::Unknown. // 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. // 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::Value packetType = PacketType::Unknown); PacketSequenceNumber sequenceNumberFromHeader(const QByteArray& packet, PacketType::Value packetType = PacketType::Unknown);

View file

@ -25,7 +25,7 @@ public:
qint64 satoshiCost = 0, const QUuid nodeUUID = QUuid()); qint64 satoshiCost = 0, const QUuid nodeUUID = QUuid());
QUuid _nodeUUID; QUuid _nodeUUID;
PacketType _currentType; PacketType::Value _currentType;
unsigned char _currentBuffer[MAX_PACKET_SIZE]; unsigned char _currentBuffer[MAX_PACKET_SIZE];
size_t _currentSize; size_t _currentSize;
qint64 _satoshiCost; qint64 _satoshiCost;

View file

@ -1936,7 +1936,7 @@ bool Octree::readSVOFromStream(unsigned long streamLength, QDataStream& inputStr
bool wantImportProgress = true; bool wantImportProgress = true;
PacketType expectedType = expectedDataPacketType(); PacketType::Value expectedType = expectedDataPacketType();
PacketVersion expectedVersion = versionForPacketType(expectedType); PacketVersion expectedVersion = versionForPacketType(expectedType);
bool hasBufferBreaks = versionHasSVOfileBreaks(expectedVersion); bool hasBufferBreaks = versionHasSVOfileBreaks(expectedVersion);
@ -1954,7 +1954,7 @@ bool Octree::readSVOFromStream(unsigned long streamLength, QDataStream& inputStr
unsigned long dataLength = HEADER_LENGTH; unsigned long dataLength = HEADER_LENGTH;
// if so, read the first byte of the file and see if it matches the expected version code // 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)); memcpy(&gotType, dataAt, sizeof(gotType));
dataAt += sizeof(expectedType); dataAt += sizeof(expectedType);
@ -2097,7 +2097,7 @@ void Octree::writeToJSONFile(const char* fileName, OctreeElement* element) {
} }
// include the "bitstream" version // include the "bitstream" version
PacketType expectedType = expectedDataPacketType(); PacketType::Value expectedType = expectedDataPacketType();
PacketVersion expectedVersion = versionForPacketType(expectedType); PacketVersion expectedVersion = versionForPacketType(expectedType);
entityDescription["Version"] = (int) expectedVersion; entityDescription["Version"] = (int) expectedVersion;
@ -2118,7 +2118,7 @@ void Octree::writeToSVOFile(const char* fileName, OctreeElement* element) {
if(file.is_open()) { if(file.is_open()) {
qCDebug(octree, "Saving binary SVO to file %s...", fileName); qCDebug(octree, "Saving binary SVO to file %s...", fileName);
PacketType expectedType = expectedDataPacketType(); PacketType::Value expectedType = expectedDataPacketType();
PacketVersion expectedVersion = versionForPacketType(expectedType); PacketVersion expectedVersion = versionForPacketType(expectedType);
bool hasBufferBreaks = versionHasSVOfileBreaks(expectedVersion); bool hasBufferBreaks = versionHasSVOfileBreaks(expectedVersion);

View file

@ -226,7 +226,7 @@ public:
// These methods will allow the OctreeServer to send your tree inbound edit packets of your // 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 // own definition. Implement these to allow your octree based server to support editing
virtual bool getWantSVOfileVersions() const { return false; } 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 { virtual bool canProcessVersion(PacketVersion thisVersion) const {
return thisVersion == versionForPacketType(expectedDataPacketType()); } return thisVersion == versionForPacketType(expectedDataPacketType()); }
virtual PacketVersion expectedVersion() const { return versionForPacketType(expectedDataPacketType()); } virtual PacketVersion expectedVersion() const { return versionForPacketType(expectedDataPacketType()); }

View file

@ -327,7 +327,7 @@ void OctreeEditPacketSender::releaseQueuedPacket(EditPacketBuffer& packetBuffer)
_releaseQueuedPacketMutex.unlock(); _releaseQueuedPacketMutex.unlock();
} }
void OctreeEditPacketSender::initializePacket(EditPacketBuffer& packetBuffer, PacketType type, int nodeClockSkew) { void OctreeEditPacketSender::initializePacket(EditPacketBuffer& packetBuffer, PacketType::Value type, int nodeClockSkew) {
packetBuffer._currentSize = packetBuffer._currentSize =
DependencyManager::get<NodeList>()->populatePacketHeader(reinterpret_cast<char*>(&packetBuffer._currentBuffer[0]), type); DependencyManager::get<NodeList>()->populatePacketHeader(reinterpret_cast<char*>(&packetBuffer._currentBuffer[0]), type);

View file

@ -101,7 +101,7 @@ protected:
void queuePacketToNode(const QUuid& nodeID, unsigned char* buffer, size_t length, qint64 satoshiCost = 0); 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 queuePendingPacketToNodes(PacketType type, unsigned char* buffer, size_t length, qint64 satoshiCost = 0);
void queuePacketToNodes(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 releaseQueuedPacket(EditPacketBuffer& packetBuffer); // releases specific queued packet
void processPreServerExistsPackets(); void processPreServerExistsPackets();

View file

@ -33,7 +33,7 @@ void OctreeHeadlessViewer::init() {
void OctreeHeadlessViewer::queryOctree() { void OctreeHeadlessViewer::queryOctree() {
char serverType = getMyNodeType(); char serverType = getMyNodeType();
PacketType packetType = getMyQueryMessageType(); PacketType::Value packetType = getMyQueryMessageType();
NodeToJurisdictionMap& jurisdictions = *_jurisdictionListener->getJurisdictions(); NodeToJurisdictionMap& jurisdictions = *_jurisdictionListener->getJurisdictions();
bool wantExtraDebugging = false; bool wantExtraDebugging = false;

View file

@ -42,7 +42,7 @@ typedef quint64 OCTREE_PACKET_SENT_TIME;
typedef uint16_t OCTREE_PACKET_INTERNAL_SECTION_SIZE; typedef uint16_t OCTREE_PACKET_INTERNAL_SECTION_SIZE;
const int MAX_OCTREE_PACKET_SIZE = MAX_PACKET_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) const unsigned int OCTREE_PACKET_EXTRA_HEADERS_SIZE = sizeof(OCTREE_PACKET_FLAGS)
+ sizeof(OCTREE_PACKET_SEQUENCE) + sizeof(OCTREE_PACKET_SENT_TIME); + sizeof(OCTREE_PACKET_SEQUENCE) + sizeof(OCTREE_PACKET_SENT_TIME);

View file

@ -62,10 +62,10 @@ void OctreeRenderer::processDatagram(const QByteArray& dataByteArray, const Shar
PerformanceWarning warn(showTimingDetails, "OctreeRenderer::processDatagram()",showTimingDetails); PerformanceWarning warn(showTimingDetails, "OctreeRenderer::processDatagram()",showTimingDetails);
unsigned int packetLength = dataByteArray.size(); unsigned int packetLength = dataByteArray.size();
PacketType command = packetTypeForPacket(dataByteArray); PacketType::Value command = packetTypeForPacket(dataByteArray);
unsigned int numBytesPacketHeader = numBytesForPacketHeader(dataByteArray); unsigned int numBytesPacketHeader = numBytesForPacketHeader(dataByteArray);
QUuid sourceUUID = uuidFromPacketHeader(dataByteArray); QUuid sourceUUID = uuidFromPacketHeader(dataByteArray);
PacketType expectedType = getExpectedPacketType(); PacketType::Value expectedType = getExpectedPacketType();
// packetVersion is the second byte // packetVersion is the second byte
PacketVersion packetVersion = dataByteArray[1]; PacketVersion packetVersion = dataByteArray[1];

View file

@ -36,8 +36,8 @@ public:
virtual ~OctreeRenderer(); virtual ~OctreeRenderer();
virtual char getMyNodeType() const = 0; virtual char getMyNodeType() const = 0;
virtual PacketType getMyQueryMessageType() const = 0; virtual PacketType::Value getMyQueryMessageType() const = 0;
virtual PacketType getExpectedPacketType() const = 0; virtual PacketType::Value getExpectedPacketType() const = 0;
virtual void renderElement(OctreeElement* element, RenderArgs* args) = 0; virtual void renderElement(OctreeElement* element, RenderArgs* args) = 0;
virtual float getSizeScale() const { return DEFAULT_OCTREE_SIZE_SCALE; } virtual float getSizeScale() const { return DEFAULT_OCTREE_SIZE_SCALE; }
virtual int getBoundaryLevelAdjust() const { return 0; } virtual int getBoundaryLevelAdjust() const { return 0; }