Commit fd2b2cf0 authored by Max Kellermann's avatar Max Kellermann

command/message: make messages/subscriptions local to the current partition

parent 438a6d75
......@@ -1354,6 +1354,9 @@ additional services.
New messages are indicated by the ``message``
idle event.
If your MPD instance has multiple partitions, note that
client-to-client messages are local to the current partition.
:command:`subscribe {NAME}`
Subscribe to a channel. The channel is created if it
does not exist already. The name may consist of
......
......@@ -78,7 +78,12 @@ handle_channels(Client &client, gcc_unused Request args, Response &r)
assert(args.empty());
std::set<std::string> channels;
const auto &partition = client.GetPartition();
for (const auto &c : *client.GetInstance().client_list) {
if (&c.GetPartition() != &partition)
continue;
const auto &subscriptions = c.GetSubscriptions();
channels.insert(subscriptions.begin(),
subscriptions.end());
......@@ -119,8 +124,11 @@ handle_send_message(Client &client, Request args, Response &r)
bool sent = false;
const ClientMessage msg(channel_name, message_text);
const auto &partition = client.GetPartition();
for (auto &c : *client.GetInstance().client_list)
if (c.PushMessage(msg))
if (&c.GetPartition() == &partition &&
c.PushMessage(msg))
sent = true;
if (sent)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment