Files
cosmopolite/clients/c/test.c

20 lines
542 B
C
Raw Normal View History

2015-06-02 22:21:28 -07:00
#include <unistd.h>
2015-06-06 10:44:46 -07:00
#include "cosmopolite.h"
2015-06-02 22:21:28 -07:00
int main(int argc, char *argv[]) {
2015-06-03 22:45:07 -07:00
char client_id[COSMO_UUID_SIZE];
cosmo_uuid(client_id);
2015-06-06 10:39:33 -07:00
cosmo *instance = cosmo_create("https://playground.cosmopolite.org/cosmopolite", client_id);
2015-06-03 22:24:07 -07:00
json_t *subject = cosmo_subject("foobar", NULL, NULL);
cosmo_subscribe(instance, subject, -1, 0);
2015-06-06 14:56:23 -07:00
json_t *message = json_string("test from C");
cosmo_send_message(instance, subject, message);
json_decref(message);
2015-06-03 22:24:07 -07:00
json_decref(subject);
2015-06-05 23:20:07 -07:00
sleep(120);
cosmo_shutdown(instance);
2015-06-02 22:21:28 -07:00
return 0;
}