diff options
author | Max Kellermann <max@duempel.org> | 2013-01-14 23:42:06 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-01-15 12:15:33 +0100 |
commit | 39439b80f5d1574e67f337a047869cf067c396b7 (patch) | |
tree | 5e28e61d4895da86189d14cde9f1e238c18079a8 /src/ClientInternal.hxx | |
parent | 396480cf94fbeda581acb6a78c42c7ec610d04a4 (diff) | |
download | mpd-39439b80f5d1574e67f337a047869cf067c396b7.tar.gz mpd-39439b80f5d1574e67f337a047869cf067c396b7.tar.xz mpd-39439b80f5d1574e67f337a047869cf067c396b7.zip |
Client: rebase on the new BufferedSocket class
Diffstat (limited to '')
-rw-r--r-- | src/ClientInternal.hxx | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/ClientInternal.hxx b/src/ClientInternal.hxx index 009568ed4..dee5d9c71 100644 --- a/src/ClientInternal.hxx +++ b/src/ClientInternal.hxx @@ -24,8 +24,8 @@ #include "Client.hxx" #include "ClientMessage.hxx" #include "CommandListBuilder.hxx" +#include "event/BufferedSocket.hxx" #include "command.h" -#include "util/PeakBuffer.hxx" #include <set> #include <string> @@ -42,20 +42,13 @@ enum { }; struct Partition; -class PeakBuffer; -class Client { +class Client final : private BufferedSocket { public: Partition &partition; struct playlist &playlist; struct player_control *player_control; - GIOChannel *channel; - guint source_id; - - /** the buffer for reading lines from the #channel */ - struct fifo_buffer *input; - unsigned permission; /** the uid of the client process, or -1 if unknown */ @@ -70,8 +63,6 @@ public: unsigned int num; /* client number */ - PeakBuffer output_buffer; - /** is this client waiting for an "idle" response? */ bool idle_waiting; @@ -98,23 +89,35 @@ public: */ std::list<ClientMessage> messages; - Client(Partition &partition, + Client(EventLoop &loop, Partition &partition, int fd, int uid, int num); ~Client(); + bool IsConnected() const { + return BufferedSocket::IsDefined(); + } + gcc_pure bool IsSubscribed(const char *channel_name) const { return subscriptions.find(channel_name) != subscriptions.end(); } - gcc_pure bool IsExpired() const { - return channel == nullptr; + return !BufferedSocket::IsDefined(); } void Close(); void SetExpired(); + + using BufferedSocket::Write; + +private: + /* virtual methods from class BufferedSocket */ + virtual InputResult OnSocketInput(const void *data, + size_t length) override; + virtual void OnSocketError(GError *error) override; + virtual void OnSocketClosed() override; }; extern unsigned int client_max_connections; @@ -142,9 +145,6 @@ enum command_return client_process_line(Client *client, char *line); void -client_write_deferred(Client *client); - -void client_write_output(Client *client); gboolean |