Boom, real passing tests.

This commit is contained in:
Ian Gulliver
2015-06-15 03:26:41 +00:00
parent 0df573171d
commit 4a6cb1f9bd
3 changed files with 87 additions and 33 deletions

View File

@@ -179,6 +179,12 @@ static void cosmo_handle_message(cosmo *instance, json_t *event) {
}
}
static void cosmo_handle_logout(cosmo *instance, json_t *event) {
if (instance->callbacks.logout) {
instance->callbacks.logout(instance->passthrough);
}
}
static void cosmo_handle_event(cosmo *instance, json_t *event) {
json_t *event_id = json_object_get(event, "event_id");
if (event_id) {
@@ -186,8 +192,10 @@ static void cosmo_handle_event(cosmo *instance, json_t *event) {
}
const char *event_type = json_string_value(json_object_get(event, "event_type"));
if (strcmp(event_type, "message") == 0) {
if (!strcmp(event_type, "message")) {
cosmo_handle_message(instance, event);
} else if (!strcmp(event_type, "logout")) {
cosmo_handle_logout(instance, event);
} else {
fprintf(stderr, "unknown event type: %s\n", event_type);
}