mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Fix API Subscription initialisation (#1354)
* Fix #1352,#1351 * Fix/Add details on client address
This commit is contained in:
@@ -98,6 +98,8 @@ void JsonAPI::initialize()
|
||||
{
|
||||
// init API, REQUIRED!
|
||||
API::init();
|
||||
// Initialise jsonCB with current instance
|
||||
_jsonCB->setSubscriptionsTo(_hyperion);
|
||||
|
||||
// setup auth interface
|
||||
connect(this, &API::onPendingTokenRequest, this, &JsonAPI::newPendingTokenRequest);
|
||||
@@ -129,6 +131,8 @@ void JsonAPI::handleMessage(const QString &messageString, const QString &httpAut
|
||||
{
|
||||
const QString ident = "JsonRpc@" + _peerAddress;
|
||||
QJsonObject message;
|
||||
//std::cout << "JsonAPI::handleMessage | [" << static_cast<int>(_hyperion->getInstanceIndex()) << "] Received: ["<< messageString.toStdString() << "]" << std::endl;
|
||||
|
||||
// parse the message
|
||||
if (!JsonUtils::parse(ident, messageString, message, _log))
|
||||
{
|
||||
|
@@ -73,7 +73,7 @@ bool JsonCB::subscribeFor(const QString& type, bool unsubscribe)
|
||||
if(type == "priorities-update")
|
||||
{
|
||||
if (unsubscribe)
|
||||
disconnect(_prioMuxer,0 ,0 ,0);
|
||||
disconnect(_prioMuxer, &PriorityMuxer::prioritiesChanged, this, &JsonCB::handlePriorityUpdate);
|
||||
else
|
||||
connect(_prioMuxer, &PriorityMuxer::prioritiesChanged, this, &JsonCB::handlePriorityUpdate, Qt::UniqueConnection);
|
||||
}
|
||||
@@ -156,6 +156,8 @@ void JsonCB::resetSubscriptions()
|
||||
|
||||
void JsonCB::setSubscriptionsTo(Hyperion* hyperion)
|
||||
{
|
||||
//std::cout << "JsonCB::setSubscriptions for instance [" << static_cast<int>(hyperion->getInstanceIndex()) << "] " << std::endl;
|
||||
|
||||
// get current subs
|
||||
QStringList currSubs(getSubscribedCommands());
|
||||
|
||||
@@ -179,11 +181,13 @@ void JsonCB::doCallback(const QString& cmd, const QVariant& data)
|
||||
QJsonObject obj;
|
||||
obj["command"] = cmd;
|
||||
|
||||
if(static_cast<QMetaType::Type>(data.type()) == QMetaType::QJsonArray)
|
||||
if(data.userType() == QMetaType::QJsonArray)
|
||||
obj["data"] = data.toJsonArray();
|
||||
else
|
||||
obj["data"] = data.toJsonObject();
|
||||
|
||||
//std::cout << "JsonCB::doCallback | [" << static_cast<int>(_hyperion->getInstanceIndex()) << "] Send: [" << QJsonDocument(obj).toJson(QJsonDocument::Compact).toStdString() << "]" << std::endl;
|
||||
|
||||
emit newCallback(obj);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user