aboutsummaryrefslogtreecommitdiff
path: root/src/ClientNew.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-01-14 23:42:06 +0100
committerMax Kellermann <max@duempel.org>2013-01-15 12:15:33 +0100
commit39439b80f5d1574e67f337a047869cf067c396b7 (patch)
tree5e28e61d4895da86189d14cde9f1e238c18079a8 /src/ClientNew.cxx
parent396480cf94fbeda581acb6a78c42c7ec610d04a4 (diff)
Client: rebase on the new BufferedSocket class
Diffstat (limited to 'src/ClientNew.cxx')
-rw-r--r--src/ClientNew.cxx31
1 files changed, 6 insertions, 25 deletions
diff --git a/src/ClientNew.cxx b/src/ClientNew.cxx
index 144c339a..42cc3470 100644
--- a/src/ClientNew.cxx
+++ b/src/ClientNew.cxx
@@ -22,7 +22,6 @@
#include "ClientList.hxx"
#include "Partition.hxx"
#include "fd_util.h"
-#include "util/fifo_buffer.h"
extern "C" {
#include "resolver.h"
}
@@ -47,45 +46,27 @@ extern "C" {
static const char GREETING[] = "OK MPD " PROTOCOL_VERSION "\n";
-Client::Client(Partition &_partition,
- int fd, int _uid, int _num)
- :partition(_partition),
+Client::Client(EventLoop &_loop, Partition &_partition,
+ int _fd, int _uid, int _num)
+ :BufferedSocket(_fd, _loop, 16384, client_max_output_buffer_size),
+ partition(_partition),
playlist(partition.playlist), player_control(&partition.pc),
- input(fifo_buffer_new(4096)),
permission(getDefaultPermissions()),
uid(_uid),
last_activity(g_timer_new()),
num(_num),
- output_buffer(16384, client_max_output_buffer_size),
idle_waiting(false), idle_flags(0),
num_subscriptions(0)
{
- assert(fd >= 0);
-
- channel = g_io_channel_new_socket(fd);
- /* GLib is responsible for closing the file descriptor */
- g_io_channel_set_close_on_unref(channel, true);
- /* NULL encoding means the stream is binary safe; the MPD
- protocol is UTF-8 only, but we are doing this call anyway
- to prevent GLib from messing around with the stream */
- g_io_channel_set_encoding(channel, NULL, NULL);
- /* we prefer to do buffering */
- g_io_channel_set_buffered(channel, false);
-
- source_id = g_io_add_watch(channel,
- GIOCondition(G_IO_IN|G_IO_ERR|G_IO_HUP),
- client_in_event, this);
}
Client::~Client()
{
g_timer_destroy(last_activity);
-
- fifo_buffer_free(input);
}
void
-client_new(Partition &partition,
+client_new(EventLoop &loop, Partition &partition,
int fd, const struct sockaddr *sa, size_t sa_length, int uid)
{
static unsigned int next_client_num;
@@ -124,7 +105,7 @@ client_new(Partition &partition,
return;
}
- Client *client = new Client(partition, fd, uid,
+ Client *client = new Client(loop, partition, fd, uid,
next_client_num++);
(void)send(fd, GREETING, sizeof(GREETING) - 1, 0);