diff --git a/src/client/Client.hxx b/src/client/Client.hxx index 031f5492e..977d638c2 100644 --- a/src/client/Client.hxx +++ b/src/client/Client.hxx @@ -83,6 +83,8 @@ public: TagMask tag_mask = TagMask::All(); private: + static constexpr size_t MAX_SUBSCRIPTIONS = 16; + /** * A list of channel names this client is subscribed to. */ @@ -94,6 +96,8 @@ private: */ unsigned num_subscriptions = 0; + static constexpr size_t MAX_MESSAGES = 64; + /** * A list of messages this client has received. */ diff --git a/src/client/Internal.hxx b/src/client/Internal.hxx index ff05e2a79..ab1de1185 100644 --- a/src/client/Internal.hxx +++ b/src/client/Internal.hxx @@ -24,9 +24,6 @@ #include -static constexpr unsigned CLIENT_MAX_SUBSCRIPTIONS = 16; -static constexpr unsigned CLIENT_MAX_MESSAGES = 64; - extern std::chrono::steady_clock::duration client_timeout; extern size_t client_max_command_list_size; extern size_t client_max_output_buffer_size; diff --git a/src/client/Subscribe.cxx b/src/client/Subscribe.cxx index 1a1367841..e0b3135f9 100644 --- a/src/client/Subscribe.cxx +++ b/src/client/Subscribe.cxx @@ -17,7 +17,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "Internal.hxx" +#include "Client.hxx" #include "Partition.hxx" #include "Idle.hxx" @@ -31,7 +31,7 @@ Client::Subscribe(const char *channel) noexcept if (!client_message_valid_channel_name(channel)) return Client::SubscribeResult::INVALID; - if (num_subscriptions >= CLIENT_MAX_SUBSCRIPTIONS) + if (num_subscriptions >= MAX_SUBSCRIPTIONS) return Client::SubscribeResult::FULL; auto r = subscriptions.insert(channel); @@ -75,7 +75,7 @@ Client::UnsubscribeAll() noexcept bool Client::PushMessage(const ClientMessage &msg) noexcept { - if (messages.size() >= CLIENT_MAX_MESSAGES || + if (messages.size() >= MAX_MESSAGES || !IsSubscribed(msg.GetChannel())) return false;