- g_print ("Connected callback\n");
- lm_connection_authenticate (connection,
- info->name, info->passwd, "TestLM",
- authentication_cb, info, FALSE, NULL);
- g_print ("Sent auth message\n");
+ lm_connection_authenticate (connection,
+ info->name, info->passwd, "TestLM",
+ authentication_cb, info, FALSE, NULL);
+}
+
+static void
+send_reply (LmConnection *connection,
+ const char *peer,
+ const char *message,
+ UserInfo *info)
+{
+ LmMessage *reply;
+ gboolean result;
+ GError *error = NULL;
+
+ reply = lm_message_new (peer, LM_MESSAGE_TYPE_MESSAGE);
+
+ lm_message_node_add_child (reply->node, "body", message);
+
+ result = lm_connection_send (connection, reply, &error);
+ lm_message_unref (reply);
+
+ if (! result) {
+ g_error ("lm_connection_send failed: error->message");
+ loudgame_quit (info, 1);
+ }
+}
+
+static void
+handle_command (LmConnection *connection,
+ const char *peer,
+ const char *command,
+ UserInfo *info)
+{
+ char *error;
+
+ if (strcmp (command, "quit") == 0) {
+ loudgame_quit (info, 0);
+ return;
+ }
+
+ error = g_strdup_printf ("Unknown command: '%s'", command);
+ send_reply (connection, peer, error, info);
+ free (error);