From: Carl Worth Date: Sat, 5 Jan 2008 23:20:36 +0000 (-0800) Subject: Add actual echo-ing capability to lm-echo X-Git-Url: https://git.cworth.org/git?p=loudgame;a=commitdiff_plain;h=2ae865aff6f9f8475d7fd8683a97142000d1a797 Add actual echo-ing capability to lm-echo --- diff --git a/lm-echo.c b/lm-echo.c index 074f4c5..312e6fe 100644 --- a/lm-echo.c +++ b/lm-echo.c @@ -77,8 +77,26 @@ handle_messages (LmMessageHandler *handler, LmMessage *m, gpointer user_data) { + LmMessage *reply; + gboolean result; + GError *error = NULL; + LmMessageNode *body; + g_print ("Incoming message from: %s\n", lm_message_node_get_attribute (m->node, "from")); + + reply = lm_message_new (lm_message_node_get_attribute (m->node, "from"), + LM_MESSAGE_TYPE_MESSAGE); + body = lm_message_node_get_child (m->node, "body"); + lm_message_node_add_child (reply->node, "body", + lm_message_node_get_value (body)); + + result = lm_connection_send (connection, reply, &error); + lm_message_unref (reply); + + if (! result) { + g_error ("lm_connection_send failed"); + } return LM_HANDLER_RESULT_REMOVE_MESSAGE; }