14 namespace swift::misc::shared_state::dbus
24 while (!m_subscriptions.isEmpty())
26 const auto channel = m_subscriptions.firstKey();
33 for (
auto client : m_hub->
clients())
35 if (client !=
this && client->m_subscriptions.value(channel).matches(param))
37 emit client->eventPosted(channel, param);
44 if (filters.
isEmpty()) { m_subscriptions.remove(channel); }
45 else { m_subscriptions.insert(channel, filters); }
47 for (
auto client : m_hub->
clients())
49 if (client !=
this) { client->requestPeerSubscriptions(channel); }
55 QSet<QString> channels;
56 for (
const auto &client : m_hub->
clients())
60 const auto &keys = client->m_subscriptions.keys();
61 const QSet subscriptions(keys.begin(), keys.end());
62 channels.unite(subscriptions);
71 for (
auto peer : m_hub->
clients())
73 if (peer !=
this) { filters.
push_back(peer->m_subscriptions.value(channel)); }
81 for (
auto handler : m_hub->
clients())
83 if (handler !=
this && handler->m_handlingChannels.contains(channel))
85 doAfter(handler->receiveRequest(channel, param),
this,
86 [
this, channel, token](QFuture<CVariant> future) {
87 emit this->replyReceived(channel, future.result(), token);
void addObject(const QString &name, QObject *object)
Add a QObject to be exposed via DBus.
Value object encapsulating information identifying a component of a modular distributed swift process...
QString toDBusObjectPath(const QString &root={}) const
Produces a DBus object path from the identifier.
void push_back(const T &value)
Appends an element at the end of the sequence.
bool isEmpty() const
Synonym for empty.
Wrapper around QVariant which provides transparent access to CValueObject methods of the contained ob...
Value object encapsulating a list of variants.
virtual ~CDuplex()
Destructor.
virtual void postEvent(const QString &channel, const swift::misc::CVariant ¶m)
Client posts an event to the server.
virtual void advertise(const QString &channel)
Client advertises that it can handle requests for the given channel.
virtual void requestPeerSubscriptions()
Client requests to be notified of all other clients' subscriptions.
CDuplex(CHub *hub, const CIdentifier &client, CDBusServer *server, QObject *parent=nullptr)
Constructor.
virtual void setSubscription(const QString &channel, const swift::misc::CVariantList &filters)
Client announces its subscription to an event channel.
virtual void submitRequest(const QString &channel, const swift::misc::CVariant ¶m, quint32 token)
Client submits a request to the server. Reply is returned via a future.
virtual void withdraw(const QString &channel)
Client advertises that it can no longer handle requests for the given channel.
Server side implementation of IHub.
const auto & clients() const
Returns a range containing all duplex objects.
Abstract interface for the spoke in a star topology.
void peerSubscriptionsReceived(const QString &channel, const swift::misc::CVariantList &filters)
Server has notified the client that other clients' event subscriptions have changed.
#define SWIFT_MISC_DUPLEX_PATH_ROOT
DBus object path root for sharedstate hub.
void doAfter(QFuture< T > future, QObject *context, F &&func)
Connect a slot or function to be invoked in the given context when a QFuture is finished.