From 3716b3faaa96aa53a3658073d31f9cd795eb6060 Mon Sep 17 00:00:00 2001 From: bel2125 Date: Fri, 11 Sep 2015 22:12:10 +0200 Subject: [PATCH] Update embedded_c example --- examples/embedded_c/Makefile | 2 +- examples/embedded_c/embedded_c.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/embedded_c/Makefile b/examples/embedded_c/Makefile index 9cd5c528..1478a90b 100644 --- a/examples/embedded_c/Makefile +++ b/examples/embedded_c/Makefile @@ -12,7 +12,7 @@ SRC = embedded_c.c TOP = ../.. CIVETWEB_LIB = libcivetweb.a -CFLAGS = -I$(TOP)/include $(COPT) +CFLAGS = -I$(TOP)/include $(COPT) -DUSE_WEBSOCKET LIBS = -lpthread include $(TOP)/resources/Makefile.in-os diff --git a/examples/embedded_c/embedded_c.c b/examples/embedded_c/embedded_c.c index c1c37e30..2ec49e79 100644 --- a/examples/embedded_c/embedded_c.c +++ b/examples/embedded_c/embedded_c.c @@ -38,7 +38,9 @@ int ExampleHandler(struct mg_connection *conn, void *cbdata) mg_printf(conn, "

To see a page from the B handler (1) click B/A

"); mg_printf(conn, "

To see a page from the B handler (2) click B/B

"); mg_printf(conn, "

To see a page from the *.foo handler click xy.foo

"); +#ifdef USE_WEBSOCKET mg_printf(conn, "

To test websocket handler click websocket

"); +#endif mg_printf(conn, "

To exit click exit

", EXIT_URI); mg_printf(conn, "\n"); return 1; @@ -81,7 +83,7 @@ int BXHandler(struct mg_connection *conn, void *cbdata) mg_printf(conn, "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n"); mg_printf(conn, ""); - mg_printf(conn, "

This is the BX handler %i!!!

", (int)cbdata); + mg_printf(conn, "

This is the BX handler %p!!!

", cbdata); mg_printf(conn, "

The actual uri is %s

", req_info->uri); mg_printf(conn, "\n"); return 1; @@ -271,8 +273,10 @@ int main(int argc, char *argv[]) /* HTTP site to open a websocket connection */ mg_set_request_handler(ctx, "/websocket", WebSocketStartHandler, 0); +#ifdef USE_WEBSOCKET /* WS site for the websocket connection */ mg_set_websocket_handler(ctx, "/websocket", WebSocketConnectHandler, WebSocketReadyHandler, WebsocketDataHandler, WebSocketCloseHandler, 0); +#endif printf("Browse files at http://localhost:%s/\n", PORT); printf("Run example at http://localhost:%s%s\n", PORT, EXAMPLE_URI);