From f6b38bbdeeaa3645e1921ccc6114d43e25dd1083 Mon Sep 17 00:00:00 2001 From: turret Date: Sat, 30 Mar 2024 21:24:36 -0500 Subject: net: add prints for data when unhandled mainly for early building process net: make curl ws_handle non-static --- util/net.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'util') diff --git a/util/net.c b/util/net.c index 42fb004..77e944f 100644 --- a/util/net.c +++ b/util/net.c @@ -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, -- cgit v1.2.3