2015-06-06 10:44:46 -07:00
|
|
|
#ifndef _COSMOPOLITE_H
|
|
|
|
|
#define _COSMOPOLITE_H
|
|
|
|
|
|
|
|
|
|
#include <jansson.h>
|
|
|
|
|
|
2015-06-28 11:18:05 -07:00
|
|
|
#include "promise.h"
|
|
|
|
|
|
2015-06-06 10:44:46 -07:00
|
|
|
#define COSMO_UUID_SIZE 37
|
|
|
|
|
|
2015-06-07 15:30:08 -07:00
|
|
|
typedef struct {
|
2015-06-24 03:01:24 +00:00
|
|
|
void (*client_id_change)(void *, const char *);
|
2015-06-18 04:27:17 +00:00
|
|
|
void (*connect)(void *);
|
2015-06-18 05:43:05 +00:00
|
|
|
void (*disconnect)(void *);
|
2015-06-19 22:27:28 +00:00
|
|
|
void (*login)(void *);
|
2015-06-15 03:26:41 +00:00
|
|
|
void (*logout)(void *);
|
2015-06-10 19:50:26 -07:00
|
|
|
void (*message)(const json_t *, void *);
|
2015-06-07 15:30:08 -07:00
|
|
|
} cosmo_callbacks;
|
|
|
|
|
|
2015-06-24 04:01:32 +00:00
|
|
|
typedef struct {
|
2015-07-06 01:11:40 +00:00
|
|
|
int placeholder;
|
2015-06-24 04:01:32 +00:00
|
|
|
} cosmo_options;
|
|
|
|
|
|
2015-06-19 22:18:24 +00:00
|
|
|
typedef struct cosmo cosmo;
|
2015-06-06 10:44:46 -07:00
|
|
|
|
2015-06-06 14:59:08 -07:00
|
|
|
void cosmo_uuid(char *uuid);
|
2015-06-06 10:44:46 -07:00
|
|
|
|
2015-06-24 04:01:32 +00:00
|
|
|
cosmo *cosmo_create(const char *base_url, const char *client_id, const cosmo_callbacks *callbacks, const cosmo_options *options, void *passthrough);
|
2015-06-06 14:59:08 -07:00
|
|
|
void cosmo_shutdown(cosmo *instance);
|
2015-06-06 10:44:46 -07:00
|
|
|
|
2015-07-05 02:59:07 +00:00
|
|
|
void cosmo_get_profile(cosmo *instance, promise *promise_obj);
|
|
|
|
|
json_t *cosmo_current_profile(cosmo *instance);
|
2015-06-06 15:32:13 -07:00
|
|
|
|
2015-06-06 10:44:46 -07:00
|
|
|
json_t *cosmo_subject(const char *name, const char *readable_only_by, const char *writeable_only_by);
|
2015-06-28 11:18:05 -07:00
|
|
|
void cosmo_subscribe(cosmo *instance, json_t *subjects, const json_int_t messages, const json_int_t last_id, promise *promise_obj);
|
|
|
|
|
void cosmo_unsubscribe(cosmo *instance, json_t *subject, promise *promise_obj);
|
|
|
|
|
void cosmo_send_message(cosmo *instance, json_t *subject, json_t *message, promise *promise_obj);
|
2015-06-06 10:44:46 -07:00
|
|
|
|
2015-06-06 17:28:49 -07:00
|
|
|
json_t *cosmo_get_messages(cosmo *instance, json_t *subject);
|
|
|
|
|
json_t *cosmo_get_last_message(cosmo *instance, json_t *subject);
|
2015-06-06 16:05:11 -07:00
|
|
|
|
2015-06-07 10:14:15 -07:00
|
|
|
// TODO
|
2015-06-28 11:18:05 -07:00
|
|
|
json_t *cosmo_get_pins(cosmo *instance, json_t *subject, promise *promise_obj);
|
|
|
|
|
void cosmo_pin(cosmo *instance, json_t *subject, json_t *message, promise *promise_obj);
|
|
|
|
|
void cosmo_unpin(cosmo *instance, json_t *subject, json_t *message, promise *promise_obj);
|
2015-06-06 16:05:11 -07:00
|
|
|
|
2015-06-06 10:44:46 -07:00
|
|
|
#endif
|