X-Git-Url: https://git.cworth.org/git?p=loudgame;a=blobdiff_plain;f=lm-echo.c;h=312e6fee7bf2728f2abcd5b2c452b68528b7114a;hp=074f4c5289c3a148b1ffe2e2aae95505ad14b1bf;hb=2ae865aff6f9f8475d7fd8683a97142000d1a797;hpb=e1c9d871680aa4491f33b97b390c797c4ebf3ceb 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; }