Client: rebase on the new BufferedSocket class

This commit is contained in:
Max Kellermann
2013-01-14 23:42:06 +01:00
parent 396480cf94
commit 39439b80f5
10 changed files with 66 additions and 304 deletions

View File

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