GLib based library to communicate with Matrix.org homeservers
Go to file
Gergely Polonkai 1834d8ada9 Make HTTP API to send the access token automatically 2016-01-05 16:20:19 +01:00
docs/reference/matrix-glib Add our own error quark 2016-01-05 15:32:44 +01:00
src Make HTTP API to send the access token automatically 2016-01-05 16:20:19 +01:00
.gitignore Add our own error quark 2016-01-05 15:32:44 +01:00
Makefile.am Initial commit with empty objects 2015-12-10 17:36:37 +01:00
README.md Add API instability warning to README 2015-12-15 11:02:43 +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. The API and ABI are both very volatile as of now; dont rely on any specific feature until the API is frozen.

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.