diff options
author | turret <turret@duck.com> | 2024-03-30 21:24:36 -0500 |
---|---|---|
committer | turret <turret@duck.com> | 2024-03-30 21:24:36 -0500 |
commit | f6b38bbdeeaa3645e1921ccc6114d43e25dd1083 (patch) | |
tree | 776bcc8958260522e83306c9b393b46c7afbe1ef /util/net.c | |
parent | e9cf9c79ff159b59cfc61887ad8a69164785a1c9 (diff) | |
download | discord-bot-skeleton-f6b38bbdeeaa3645e1921ccc6114d43e25dd1083.tar.gz discord-bot-skeleton-f6b38bbdeeaa3645e1921ccc6114d43e25dd1083.tar.bz2 discord-bot-skeleton-f6b38bbdeeaa3645e1921ccc6114d43e25dd1083.zip |
net: add prints for data when unhandled
mainly for early building process
net: make curl ws_handle non-static
Diffstat (limited to 'util/net.c')
-rw-r--r-- | util/net.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -40,7 +40,7 @@ static struct { #undef E } ev_handlers; -static CURL *ws_handle; +CURL *ws_handle; static char *gateway_url; static char *token_header; @@ -203,6 +203,10 @@ static void ws_handle_event(cJSON *event) int (*ev_handler)(cJSON *) = *ev_get_handler(ev); if(ev_handler != NULL) { ev_handler(data); + } else { + char *ev_payload = cJSON_Print(data); + print("ws: unhandled event %s (data below)\n%s", event, ev_payload); + free(ev_payload); } break; case 1: /* Heartbeat request */ @@ -217,9 +221,11 @@ static void ws_handle_event(cJSON *event) break; } /* FALLTHROUGH */ - case 7: /* Reconnect */ + case 7: ; /* Reconnect */ /* TODO */ - panic("ws: cannot reconnect to ws after failure (Not supported)"); + char *msg = cJSON_Print(data); + panic("ws: cannot reconnect to ws after failure (Not supported)\n%s", msg); + free(msg); /* at least the effort is there (not a memory leak) */ break; case 10: ; /* Hello */ int heartbeat_wait = cJSON_GetObjectItem(data, |