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:
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user