diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2010-08-22 20:25:07 +0200 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2010-08-22 20:25:07 +0200 |
commit | 62a18a9e2bf67a83db4599459c55781d88e10e55 (patch) | |
tree | e95c2621e35f0d29677fec906f09d35692a45e50 | |
parent | 9558cc7031e84afc00eea62de22a494b34d653e9 (diff) |
Added ping command.
-rw-r--r-- | commands.c | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -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"); |