diff options
-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"); |