ClientInternal: move class Client to Client.hxx
Publish the Client API, preparing to move more code into the Client class.
This commit is contained in:
@@ -20,15 +20,103 @@
|
||||
#ifndef MPD_CLIENT_H
|
||||
#define MPD_CLIENT_H
|
||||
|
||||
#include "check.h"
|
||||
#include "ClientMessage.hxx"
|
||||
#include "CommandListBuilder.hxx"
|
||||
#include "event/FullyBufferedSocket.hxx"
|
||||
#include "event/TimeoutMonitor.hxx"
|
||||
#include "Compiler.h"
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
struct sockaddr;
|
||||
class EventLoop;
|
||||
struct Partition;
|
||||
class Client;
|
||||
|
||||
class Client final : private FullyBufferedSocket, TimeoutMonitor {
|
||||
public:
|
||||
Partition &partition;
|
||||
struct playlist &playlist;
|
||||
struct player_control &player_control;
|
||||
|
||||
unsigned permission;
|
||||
|
||||
/** the uid of the client process, or -1 if unknown */
|
||||
int uid;
|
||||
|
||||
CommandListBuilder cmd_list;
|
||||
|
||||
unsigned int num; /* client number */
|
||||
|
||||
/** is this client waiting for an "idle" response? */
|
||||
bool idle_waiting;
|
||||
|
||||
/** idle flags pending on this client, to be sent as soon as
|
||||
the client enters "idle" */
|
||||
unsigned idle_flags;
|
||||
|
||||
/** idle flags that the client wants to receive */
|
||||
unsigned idle_subscriptions;
|
||||
|
||||
/**
|
||||
* A list of channel names this client is subscribed to.
|
||||
*/
|
||||
std::set<std::string> subscriptions;
|
||||
|
||||
/**
|
||||
* The number of subscriptions in #subscriptions. Used to
|
||||
* limit the number of subscriptions.
|
||||
*/
|
||||
unsigned num_subscriptions;
|
||||
|
||||
/**
|
||||
* A list of messages this client has received.
|
||||
*/
|
||||
std::list<ClientMessage> messages;
|
||||
|
||||
Client(EventLoop &loop, Partition &partition,
|
||||
int fd, int uid, int num);
|
||||
|
||||
bool IsConnected() const {
|
||||
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();
|
||||
}
|
||||
|
||||
void Close();
|
||||
void SetExpired();
|
||||
|
||||
using FullyBufferedSocket::Write;
|
||||
|
||||
/**
|
||||
* Send "idle" response to this client.
|
||||
*/
|
||||
void IdleNotify();
|
||||
void IdleAdd(unsigned flags);
|
||||
bool IdleWait(unsigned flags);
|
||||
|
||||
private:
|
||||
/* virtual methods from class BufferedSocket */
|
||||
virtual InputResult OnSocketInput(void *data, size_t length) override;
|
||||
virtual void OnSocketError(Error &&error) override;
|
||||
virtual void OnSocketClosed() override;
|
||||
|
||||
/* virtual methods from class TimeoutMonitor */
|
||||
virtual void OnTimeout() override;
|
||||
};
|
||||
|
||||
void client_manager_init(void);
|
||||
|
||||
|
Reference in New Issue
Block a user