mirror of
https://github.com/clangen/musikcube.git
synced 2024-10-02 13:02:35 +00:00
Fixed an issue with message queue target registration in libraries.
This commit is contained in:
parent
6f302cd374
commit
3e22c82a53
@ -67,13 +67,10 @@ LibraryFactory::~LibraryFactory() {
|
|||||||
|
|
||||||
ILibraryPtr LibraryFactory::AddLibrary(int id, ILibrary::Type type, const std::string& name) {
|
ILibraryPtr LibraryFactory::AddLibrary(int id, ILibrary::Type type, const std::string& name) {
|
||||||
ILibraryPtr library = (type == ILibrary::Type::Local)
|
ILibraryPtr library = (type == ILibrary::Type::Local)
|
||||||
? library::LocalLibrary::Create(name, id)
|
? library::LocalLibrary::Create(name, id, sMessageQueue)
|
||||||
: library::RemoteLibrary::Create(name, id);
|
: library::RemoteLibrary::Create(name, id, sMessageQueue);
|
||||||
|
|
||||||
if (library) {
|
if (library) {
|
||||||
if (sMessageQueue) {
|
|
||||||
library->SetMessageQueue(*sMessageQueue);
|
|
||||||
}
|
|
||||||
this->libraries.push_back(library);
|
this->libraries.push_back(library);
|
||||||
this->libraryMap[id] = library;
|
this->libraryMap[id] = library;
|
||||||
this->LibrariesUpdated();
|
this->LibrariesUpdated();
|
||||||
|
@ -84,16 +84,20 @@ class LocalLibrary::QueryCompletedMessage: public Message {
|
|||||||
QueryContextPtr context;
|
QueryContextPtr context;
|
||||||
};
|
};
|
||||||
|
|
||||||
ILibraryPtr LocalLibrary::Create(std::string name, int id) {
|
ILibraryPtr LocalLibrary::Create(std::string name, int id, MessageQueue* messageQueue) {
|
||||||
ILibraryPtr lib(new LocalLibrary(name, id));
|
ILibraryPtr lib(new LocalLibrary(name, id, messageQueue));
|
||||||
return lib;
|
return lib;
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalLibrary::LocalLibrary(std::string name,int id)
|
LocalLibrary::LocalLibrary(std::string name, int id, MessageQueue* messageQueue)
|
||||||
: name(name)
|
: name(name)
|
||||||
, id(id)
|
, id(id)
|
||||||
, exit(false)
|
, exit(false)
|
||||||
, messageQueue(nullptr) {
|
, messageQueue(messageQueue) {
|
||||||
|
if (this->messageQueue) {
|
||||||
|
this->messageQueue->Register(this);
|
||||||
|
}
|
||||||
|
|
||||||
this->identifier = std::to_string(id);
|
this->identifier = std::to_string(id);
|
||||||
|
|
||||||
this->db.Open(this->GetDatabaseFilename().c_str());
|
this->db.Open(this->GetDatabaseFilename().c_str());
|
||||||
|
@ -59,8 +59,9 @@ namespace musik { namespace core { namespace library {
|
|||||||
public:
|
public:
|
||||||
using LocalQuery = musik::core::library::query::QueryBase;
|
using LocalQuery = musik::core::library::query::QueryBase;
|
||||||
using LocalQueryPtr = std::shared_ptr<LocalQuery>;
|
using LocalQueryPtr = std::shared_ptr<LocalQuery>;
|
||||||
|
using MessageQueue = musik::core::runtime::IMessageQueue;
|
||||||
|
|
||||||
static ILibraryPtr Create(std::string name, int id);
|
static ILibraryPtr Create(std::string name, int id, MessageQueue* messageQueue);
|
||||||
|
|
||||||
LocalLibrary(const LocalLibrary&) = delete;
|
LocalLibrary(const LocalLibrary&) = delete;
|
||||||
virtual ~LocalLibrary();
|
virtual ~LocalLibrary();
|
||||||
@ -107,7 +108,7 @@ namespace musik { namespace core { namespace library {
|
|||||||
using QueryContextPtr = std::shared_ptr<QueryContext>;
|
using QueryContextPtr = std::shared_ptr<QueryContext>;
|
||||||
using QueryList = std::list<QueryContextPtr>;
|
using QueryList = std::list<QueryContextPtr>;
|
||||||
|
|
||||||
LocalLibrary(std::string name, int id); /* ctor */
|
LocalLibrary(std::string name, int id, MessageQueue* messageQueue); /* ctor */
|
||||||
|
|
||||||
void RunQuery(QueryContextPtr context, bool notify = true);
|
void RunQuery(QueryContextPtr context, bool notify = true);
|
||||||
void ThreadProc();
|
void ThreadProc();
|
||||||
|
@ -88,20 +88,23 @@ class RemoteLibrary::QueryCompletedMessage: public Message {
|
|||||||
QueryContextPtr context;
|
QueryContextPtr context;
|
||||||
};
|
};
|
||||||
|
|
||||||
ILibraryPtr RemoteLibrary::Create(std::string name, int id) {
|
ILibraryPtr RemoteLibrary::Create(std::string name, int id, MessageQueue* messageQueue) {
|
||||||
ILibraryPtr lib(new RemoteLibrary(name, id));
|
ILibraryPtr lib(new RemoteLibrary(name, id, messageQueue));
|
||||||
return lib;
|
return lib;
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoteLibrary::RemoteLibrary(std::string name, int id)
|
RemoteLibrary::RemoteLibrary(std::string name, int id, MessageQueue* messageQueue)
|
||||||
: name(name)
|
: name(name)
|
||||||
, id(id)
|
, id(id)
|
||||||
, exit(false)
|
, exit(false)
|
||||||
, messageQueue(nullptr)
|
, messageQueue(messageQueue)
|
||||||
, wsc(this) {
|
, wsc(this) {
|
||||||
this->identifier = std::to_string(id);
|
this->identifier = std::to_string(id);
|
||||||
this->thread = new std::thread(std::bind(&RemoteLibrary::ThreadProc, this));
|
this->thread = new std::thread(std::bind(&RemoteLibrary::ThreadProc, this));
|
||||||
this->ReloadConnectionFromPreferences();
|
this->ReloadConnectionFromPreferences();
|
||||||
|
if (this->messageQueue) {
|
||||||
|
this->messageQueue->Register(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoteLibrary::~RemoteLibrary() {
|
RemoteLibrary::~RemoteLibrary() {
|
||||||
|
@ -60,7 +60,9 @@ namespace musik { namespace core { namespace library {
|
|||||||
public:
|
public:
|
||||||
using Client = musik::core::net::WebSocketClient;
|
using Client = musik::core::net::WebSocketClient;
|
||||||
using Query = std::shared_ptr<musik::core::db::ISerializableQuery>;
|
using Query = std::shared_ptr<musik::core::db::ISerializableQuery>;
|
||||||
static ILibraryPtr Create(std::string name, int id);
|
using MessageQueue = musik::core::runtime::IMessageQueue;
|
||||||
|
|
||||||
|
static ILibraryPtr Create(std::string name, int id, MessageQueue* messageQueue);
|
||||||
|
|
||||||
RemoteLibrary(const RemoteLibrary&) = delete;
|
RemoteLibrary(const RemoteLibrary&) = delete;
|
||||||
virtual ~RemoteLibrary();
|
virtual ~RemoteLibrary();
|
||||||
@ -109,7 +111,7 @@ namespace musik { namespace core { namespace library {
|
|||||||
using QueryContextPtr = std::shared_ptr<QueryContext>;
|
using QueryContextPtr = std::shared_ptr<QueryContext>;
|
||||||
using QueryList = std::list<QueryContextPtr>;
|
using QueryList = std::list<QueryContextPtr>;
|
||||||
|
|
||||||
RemoteLibrary(std::string name, int id); /* ctor */
|
RemoteLibrary(std::string name, int id, MessageQueue* messageQueue); /* ctor */
|
||||||
|
|
||||||
void RunQuery(QueryContextPtr context);
|
void RunQuery(QueryContextPtr context);
|
||||||
void RunQueryOnLoopback(QueryContextPtr context);
|
void RunQueryOnLoopback(QueryContextPtr context);
|
||||||
|
Loading…
Reference in New Issue
Block a user