mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
even more changes
Signed-off-by: Paulchen-Panther <Paulchen--Panter@gmx.net>
This commit is contained in:
@@ -22,7 +22,8 @@ enum Components
|
||||
COMP_IMAGE,
|
||||
COMP_EFFECT,
|
||||
COMP_PROTOSERVER,
|
||||
COMP_LEDDEVICE
|
||||
COMP_LEDDEVICE,
|
||||
COMP_FLATBUFSERVER
|
||||
};
|
||||
|
||||
inline const char* componentToString(Components c)
|
||||
@@ -42,6 +43,7 @@ inline const char* componentToString(Components c)
|
||||
case COMP_IMAGE: return "Image";
|
||||
case COMP_PROTOSERVER: return "Proto Server";
|
||||
case COMP_LEDDEVICE: return "LED device";
|
||||
case COMP_FLATBUFSERVER: return "Image Receiver";
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
@@ -63,6 +65,7 @@ inline const char* componentToIdString(Components c)
|
||||
case COMP_IMAGE: return "IMAGE";
|
||||
case COMP_PROTOSERVER: return "PROTOSERVER";
|
||||
case COMP_LEDDEVICE: return "LEDDEVICE";
|
||||
case COMP_FLATBUFSERVER: return "FLATBUFSERVER";
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
@@ -83,7 +86,7 @@ inline Components stringToComponent(QString component)
|
||||
if (component == "IMAGE") return COMP_IMAGE;
|
||||
if (component == "PROTOSERVER") return COMP_PROTOSERVER;
|
||||
if (component == "LEDDEVICE") return COMP_LEDDEVICE;
|
||||
|
||||
if (component == "FLATBUFSERVER") return COMP_FLATBUFSERVER;
|
||||
return COMP_INVALID;
|
||||
}
|
||||
|
||||
|
34
include/utils/NetUtils.h
Normal file
34
include/utils/NetUtils.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
#include <utils/Logger.h>
|
||||
|
||||
#include <QTcpServer>
|
||||
|
||||
namespace NetUtils {
|
||||
///
|
||||
/// @brief Check if the port is available for listening
|
||||
/// @param[in/out] port The port to test, will be incremented if port is in use
|
||||
/// @param log The logger of the caller to print
|
||||
/// @return True on success else false
|
||||
///
|
||||
static const bool portAvailable(quint16& port, Logger* log)
|
||||
{
|
||||
const quint16 prevPort = port;
|
||||
QTcpServer server;
|
||||
bool corrected = false;
|
||||
while (!server.listen(QHostAddress::Any, port))
|
||||
{
|
||||
corrected = true;
|
||||
Warning(log,"Port '%d' is already in use, will increment", port);
|
||||
port ++;
|
||||
}
|
||||
server.close();
|
||||
if(corrected)
|
||||
{
|
||||
Warning(log, "The requested Port '%d' was already in use, will use Port '%d' instead", prevPort, port);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@@ -16,6 +16,14 @@ class Stats : public QObject
|
||||
|
||||
public:
|
||||
Stats();
|
||||
static Stats* getInstance() { return instance; };
|
||||
static Stats* instance;
|
||||
|
||||
void handleDataUpdate(const QJsonObject& config);
|
||||
|
||||
private:
|
||||
friend class HyperionDaemon;
|
||||
Stats(const QJsonObject& config);
|
||||
~Stats();
|
||||
|
||||
private:
|
||||
|
@@ -29,6 +29,7 @@ enum type {
|
||||
WEBSERVER,
|
||||
INSTCAPTURE,
|
||||
NETWORK,
|
||||
FLATBUFSERVER,
|
||||
INVALID
|
||||
};
|
||||
|
||||
@@ -62,6 +63,7 @@ inline QString typeToString(const type& type)
|
||||
case WEBSERVER: return "webConfig";
|
||||
case INSTCAPTURE: return "instCapture";
|
||||
case NETWORK: return "network";
|
||||
case FLATBUFSERVER: return "flatbufServer";
|
||||
default: return "invalid";
|
||||
}
|
||||
}
|
||||
@@ -94,6 +96,7 @@ inline type stringToType(const QString& type)
|
||||
else if (type == "webConfig") return WEBSERVER;
|
||||
else if (type == "instCapture") return INSTCAPTURE;
|
||||
else if (type == "network") return NETWORK;
|
||||
else if (type == "flatbufServer") return FLATBUFSERVER;
|
||||
else return INVALID;
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user