From 39439b80f5d1574e67f337a047869cf067c396b7 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 14 Jan 2013 23:42:06 +0100 Subject: Client: rebase on the new BufferedSocket class --- src/ClientInternal.hxx | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'src/ClientInternal.hxx') diff --git a/src/ClientInternal.hxx b/src/ClientInternal.hxx index 009568ed..dee5d9c7 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 #include @@ -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 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; @@ -141,9 +144,6 @@ client_read(Client *client); enum command_return client_process_line(Client *client, char *line); -void -client_write_deferred(Client *client); - void client_write_output(Client *client); -- cgit v1.2.3