From 62a18a9e2bf67a83db4599459c55781d88e10e55 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Sun, 22 Aug 2010 20:25:07 +0200 Subject: Added ping command. --- commands.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'commands.c') diff --git a/commands.c b/commands.c index 5a2d69e..823b132 100644 --- a/commands.c +++ b/commands.c @@ -54,9 +54,20 @@ static void commands_list(GSocketConnection *connection, const gchar *cmd) { g_string_free(string, TRUE); } +static void commands_ping(GSocketConnection *connection, const gchar *cmd) { + GError *error = NULL; + GSocket *socket = g_socket_connection_get_socket(connection); + if(g_socket_send(socket, "pong\n", 5, NULL, NULL) == -1) { + g_warning(error->message); + g_error_free(error); + } +} + void commands_handle(GSocketConnection *connection, const gchar *cmd) { g_debug(cmd); - if(g_strncasecmp(cmd, "list", 4) == 0) { + if(g_strncasecmp(cmd, "ping", 4) == 0) { + commands_ping(connection, cmd); + } else if(g_strncasecmp(cmd, "list", 4) == 0) { commands_list(connection, cmd); } else { g_debug("unknown command"); -- cgit v1.2.3