LmConnection

LmConnection — A client connection to the server

Synopsis


Description

An example of how to use Loudmouth with the synchronous API.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
int
main (int argc, char **argv)
{
        LmConnection *connection;
        GError       *error = NULL;
        gint          i;
    LmMessage    *m;
        connection = lm_connection_new ("myserver");
        if (!lm_connection_open_and_block (connection, &error)) {
                g_error ("Failed to open: %s\n", error->message);
        }
    if (!lm_connection_authenticate_and_block (connection,
                           "username", "password",
                           "resource",
                           &error)) {
        g_error ("Failed to authenticate: %s\n", error->message);
    }
    m = lm_message_new ("recipient", LM_MESSAGE_TYPE_MESSAGE);
    lm_message_node_add_child (m->node, "body", "message");
    if (!lm_connection_send (connection, m, &error)) {
        g_error ("Send failed: %s\n", error->message);
    }
    lm_message_unref (m);
    lm_connection_close (connection, NULL);
    lm_connection_unref (connection);
        return 0;
}

Details