mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 04:44:08 +02:00
Move metadata generation to DomainMetadata
This commit is contained in:
parent
87e27d9570
commit
18696144f1
4 changed files with 73 additions and 35 deletions
51
domain-server/src/DomainMetadata.cpp
Normal file
51
domain-server/src/DomainMetadata.cpp
Normal file
|
@ -0,0 +1,51 @@
|
|||
//
|
||||
// DomainMetadata.cpp
|
||||
// domain-server/src
|
||||
//
|
||||
// Created by Zach Pomerantz on 5/25/2016.
|
||||
// Copyright 2016 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
||||
#include "DomainMetadata.h"
|
||||
|
||||
#include <DependencyManager.h>
|
||||
#include <LimitedNodeList.h>
|
||||
|
||||
#include "DomainServerNodeData.h"
|
||||
|
||||
QVariantMap getMetadata() {
|
||||
static const QString DEFAULT_HOSTNAME = "*";
|
||||
|
||||
auto nodeList = DependencyManager::get<LimitedNodeList>();
|
||||
int numConnectedUnassigned = 0;
|
||||
QVariantMap userHostnames;
|
||||
|
||||
// figure out the breakdown of currently connected interface clients
|
||||
nodeList->eachNode([&numConnectedUnassigned, &userHostnames](const SharedNodePointer& node) {
|
||||
auto linkedData = node->getLinkedData();
|
||||
if (linkedData) {
|
||||
auto nodeData = static_cast<DomainServerNodeData*>(linkedData);
|
||||
|
||||
if (!nodeData->wasAssigned()) {
|
||||
++numConnectedUnassigned;
|
||||
|
||||
// increment the count for this hostname (or the default if we don't have one)
|
||||
auto placeName = nodeData->getPlaceName();
|
||||
auto hostname = placeName.isEmpty() ? DEFAULT_HOSTNAME : placeName;
|
||||
userHostnames[hostname] = userHostnames[hostname].toInt() + 1;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
QVariantMap metadata;
|
||||
|
||||
static const QString HEARTBEAT_NUM_USERS_KEY = "num_users";
|
||||
metadata[HEARTBEAT_NUM_USERS_KEY] = numConnectedUnassigned;
|
||||
|
||||
static const QString HEARTBEAT_USER_HOSTNAMES_KEY = "user_hostnames";
|
||||
metadata[HEARTBEAT_USER_HOSTNAMES_KEY] = userHostnames;
|
||||
|
||||
return metadata;
|
||||
}
|
21
domain-server/src/DomainMetadata.h
Normal file
21
domain-server/src/DomainMetadata.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
//
|
||||
// DomainMetadata.h
|
||||
// domain-server/src
|
||||
//
|
||||
// Created by Zach Pomerantz on 5/25/2016.
|
||||
// Copyright 2016 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
||||
#ifndef hifi_DomainMetadata_h
|
||||
#define hifi_DomainMetadata_h
|
||||
|
||||
#include <QVariantMap>
|
||||
|
||||
QVariantMap getMetadata();
|
||||
|
||||
// TODO: Encapsulate
|
||||
class DomainMetadata { };
|
||||
|
||||
#endif // hifi_DomainMetadata_h
|
|
@ -1067,41 +1067,6 @@ void DomainServer::performIPAddressUpdate(const HifiSockAddr& newPublicSockAddr)
|
|||
sendHeartbeatToMetaverse(newPublicSockAddr.getAddress().toString());
|
||||
}
|
||||
|
||||
QVariantMap getMetadata() {
|
||||
static const QString DEFAULT_HOSTNAME = "*";
|
||||
|
||||
auto nodeList = DependencyManager::get<LimitedNodeList>();
|
||||
int numConnectedUnassigned = 0;
|
||||
QVariantMap userHostnames;
|
||||
|
||||
// figure out the breakdown of currently connected interface clients
|
||||
nodeList->eachNode([&numConnectedUnassigned, &userHostnames](const SharedNodePointer& node) {
|
||||
auto linkedData = node->getLinkedData();
|
||||
if (linkedData) {
|
||||
auto nodeData = static_cast<DomainServerNodeData*>(linkedData);
|
||||
|
||||
if (!nodeData->wasAssigned()) {
|
||||
++numConnectedUnassigned;
|
||||
|
||||
// increment the count for this hostname (or the default if we don't have one)
|
||||
auto placeName = nodeData->getPlaceName();
|
||||
auto hostname = placeName.isEmpty() ? DEFAULT_HOSTNAME : placeName;
|
||||
userHostnames[hostname] = userHostnames[hostname].toInt() + 1;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
QVariantMap metadata;
|
||||
|
||||
static const QString HEARTBEAT_NUM_USERS_KEY = "num_users";
|
||||
metadata[HEARTBEAT_NUM_USERS_KEY] = numConnectedUnassigned;
|
||||
|
||||
static const QString HEARTBEAT_USER_HOSTNAMES_KEY = "user_hostnames";
|
||||
metadata[HEARTBEAT_USER_HOSTNAMES_KEY] = userHostnames;
|
||||
|
||||
return metadata;
|
||||
}
|
||||
|
||||
void DomainServer::sendHeartbeatToMetaverse(const QString& networkAddress) {
|
||||
auto nodeList = DependencyManager::get<LimitedNodeList>();
|
||||
const QUuid& domainID = nodeList->getSessionUUID();
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <LimitedNodeList.h>
|
||||
|
||||
#include "DomainGatekeeper.h"
|
||||
#include "DomainMetadata.h"
|
||||
#include "DomainServerSettingsManager.h"
|
||||
#include "DomainServerWebSessionData.h"
|
||||
#include "WalletTransaction.h"
|
||||
|
|
Loading…
Reference in a new issue