Handle #1497 - handshake format

This commit is contained in:
Sergey Lyubka committed 2022-03-21 15:17:09 +00:00
1 parent 0fbc4b8ff4
commit ad4812218d
5 files changed
+15 -11

No files matched your search

+4 -1
View File
@@ -11,7 +11,9 @@ static const char *s_url = "ws://localhost:8000/websocket";
// Print websocket response and signal that we're done
static void fn(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
if (ev == MG_EV_ERROR) {
if (ev == MG_EV_OPEN) {
c->is_hexdumping = 1;
} else if (ev == MG_EV_ERROR) {
// On error, log error message
MG_ERROR(("%p %s", c->fd, (char *) ev_data));
} else if (ev == MG_EV_WS_OPEN) {
@@ -33,6 +35,7 @@ int main(void) {
bool done = false; // Event handler flips it to true
struct mg_connection *c; // Client connection
mg_mgr_init(&mgr); // Initialise event manager
mg_log_set("4");
c = mg_ws_connect(&mgr, s_url, fn, &done, NULL); // Create client
while (c && done == false) mg_mgr_poll(&mgr, 1000); // Wait for echo
mg_mgr_free(&mgr); // Deallocate resources