Implement event_stream

This commit is contained in:
Gergely Polonkai 2016-01-12 17:10:02 +01:00
parent c6f7c7dd56
commit 2a96aaa6af
2 changed files with 43 additions and 1 deletions

View File

@ -869,6 +869,33 @@ i_initial_sync(MatrixAPI *api,
err);
}
static void
i_event_stream(MatrixAPI *api,
MatrixAPICallback callback,
gpointer user_data,
const gchar *from_token,
gulong timeout,
GError **err)
{
GHashTable *params;
params = create_query_params();
if (from_token) {
g_hash_table_replace(params, "from", g_strdup(from_token));
}
if (timeout != 0) {
g_hash_table_replace(params,
"timeout", g_strdup_printf("%ul", timeout));
}
_send(MATRIX_HTTP_API(api),
callback, user_data,
"GET", "events", params, NULL,
err);
}
static void
matrix_http_api_matrix_api_init(MatrixAPIInterface *iface)
{
@ -881,4 +908,5 @@ matrix_http_api_matrix_api_init(MatrixAPIInterface *iface)
iface->login = i_login;
iface->create_room = i_create_room;
iface->initial_sync = i_initial_sync;
iface->event_stream = i_event_stream;
}

View File

@ -30,6 +30,17 @@ static GOptionEntry entries[] = {
{"password", 'p', 0, G_OPTION_ARG_STRING, &password},
};
static void
initial_sync_finished(MatrixAPI *api,
JsonNode *content,
gpointer data,
GError *err)
{
g_printf("initialSync finished\n");
matrix_api_event_stream(MATRIX_API(api), NULL, NULL, NULL, 0, NULL);
}
static void
create_room_finished(MatrixAPI *api,
JsonNode *content,
@ -42,7 +53,10 @@ create_room_finished(MatrixAPI *api,
g_printf("Room registered\n");
}
matrix_api_initial_sync(MATRIX_API(api), NULL, NULL, 10, TRUE, NULL);
matrix_api_initial_sync(MATRIX_API(api),
initial_sync_finished,
data, 10, TRUE,
NULL);
}
static void