summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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");