GLib based library to communicate with Matrix.org homeservers
Go to file
Gergely Polonkai 10b6296565 Create a test client 2015-12-15 10:08:12 +01:00
docs/reference/matrix-glib Implement /createRoom 2015-12-15 09:36:41 +01:00
src Create a test client 2015-12-15 10:08:12 +01:00
.gitignore Create a test client 2015-12-15 10:08:12 +01:00
Makefile.am Initial commit with empty objects 2015-12-10 17:36:37 +01:00
README.md Add README with examples 2015-12-10 22:25:56 +01:00
autogen.sh Initial commit with empty objects 2015-12-10 17:36:37 +01:00
configure.ac Move MatrixAPI to an interface 2015-12-11 14:15:42 +01:00

README.md

Matrix Client SDK for GLib

This is a Matrix client-server SDK for GLib >= 2.40. As of now it mostly mimics the official Python SDK.

Usage

The SDK provides 2 layers of interaction. The low-level layer just wraps the raw HTTP API calls. The high-level layer wraps the low-level layer and provides an object model to perform actions on.

Client


#include <matrix-glib/matrix-client.h>

gchar *token = NULL;
MatrixClient *client = matrix_client_new("http://localhost:8008", NULL);
matrix_client_register_with_password(client, "foobar", "monkey”);
g_object_get(client, "token", &token, NULL);
room = matrix_client_create_room(client, "my_room_alias");
matrix_room_send_text(room, "Hello!");

API

#include <matrix-glib/matrix-api.h>

static void
sync_finished(MatrixAPI *api,
              MatrixAPIResponse *response,
              gpointer data)
{
    /* Do something with the response */
}

static void
message_sent(MatrixAPI *api,
             MatrixAPIResponse *response,
             gpointer data)
{
    /* Do something with the response */
}

matrix = matrix_api_new("https://matrix.org", "some_token");
g_signal_connect(G_OBJECT(api),
                 "request-finished",
                 G_CALLBACK(sync_finished),
                 NULL);
matrix_api_initial_sync(matrix, sync_finished);
matrix_api_send_message(matrix, "!roomid:matrix.org", "Hello!", message_sent);

Structure

The SDK is split into two modules: MatrixAPI and MatrixClient.

API

This contains the raw HTTP API calls and has minimal business logic. You can set the access token (token) to use for requests as well as set a custom transaction ID (txn_id) which will be incremented for each request.

Client

This encapsulates the API module and provides object models such as Room.