From 75ba961e97606030d1c976696fb8623fbb0e27df Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 19 Oct 2013 19:44:45 +0200 Subject: Client: move message functions into the class --- src/Client.hxx | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'src/Client.hxx') diff --git a/src/Client.hxx b/src/Client.hxx index 13a4a14e7..cbb0cbafc 100644 --- a/src/Client.hxx +++ b/src/Client.hxx @@ -86,11 +86,6 @@ public: return FullyBufferedSocket::IsDefined(); } - gcc_pure - bool IsSubscribed(const char *channel_name) const { - return subscriptions.find(channel_name) != subscriptions.end(); - } - gcc_pure bool IsExpired() const { return !FullyBufferedSocket::IsDefined(); @@ -132,6 +127,30 @@ public: void IdleAdd(unsigned flags); bool IdleWait(unsigned flags); + enum class SubscribeResult { + /** success */ + OK, + + /** invalid channel name */ + INVALID, + + /** already subscribed to this channel */ + ALREADY, + + /** too many subscriptions */ + FULL, + }; + + gcc_pure + bool IsSubscribed(const char *channel_name) const { + return subscriptions.find(channel_name) != subscriptions.end(); + } + + SubscribeResult Subscribe(const char *channel); + bool Unsubscribe(const char *channel); + void UnsubscribeAll(); + bool PushMessage(const ClientMessage &msg); + private: /* virtual methods from class BufferedSocket */ virtual InputResult OnSocketInput(void *data, size_t length) override; -- cgit v1.2.3