1
0
mirror of https://github.com/lammertb/libhttp.git synced 2025-07-29 21:01:13 +03:00

Update websocket example - use new API functions

This commit is contained in:
bel
2014-08-10 23:49:49 +02:00
parent 64c97d56e4
commit 56389ad023
5 changed files with 49 additions and 65 deletions

View File

@ -22,12 +22,13 @@ int main(void)
NULL
};
websock_init_lib();
callback_funcs.init_context = websock_init_lib;
callback_funcs.exit_context = websock_exit_lib;
callback_funcs.websocket_ready = websocket_ready_handler;
callback_funcs.websocket_data = websocket_data_handler;
callback_funcs.connection_close = connection_close_handler;
ctx = mg_start(&callback_funcs, NULL, server_options);
printf("Connect to localhost:%s/websock.htm\n", mg_get_option(ctx, "listening_ports"));
puts("Enter an (ASCII) character or * to exit:");
for (;;) {
@ -37,11 +38,10 @@ int main(void)
break;
}
inbuf[0] = toupper(inbuf[0]);
websock_send_broadcast(inbuf, 1);
websock_send_broadcast(ctx, inbuf, 1);
}
mg_stop(ctx);
websock_exit_lib();
return 0;
}