summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2010-08-22 20:25:07 +0200
committerJon Bergli Heier <snakebite@jvnv.net>2010-08-22 20:25:07 +0200
commit62a18a9e2bf67a83db4599459c55781d88e10e55 (patch)
treee95c2621e35f0d29677fec906f09d35692a45e50
parent9558cc7031e84afc00eea62de22a494b34d653e9 (diff)
Added ping command.
-rw-r--r--commands.c13
1 files changed, 12 insertions, 1 deletions
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");