Client: move message functions into the class

This commit is contained in:
Max Kellermann
2013-10-19 19:44:45 +02:00
parent c2d5ce0ca2
commit 75ba961e97
5 changed files with 64 additions and 96 deletions

View File

@@ -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;