From be548e6f934128d8ad12190b9b7849f9f91fc517 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 18 Jan 2013 10:46:56 +0100 Subject: Update libwebsocket to v.1.0 --- configure.in | 22 +--------------------- src/http.cc | 33 +++++++++++++++++++++++++++++---- src/muniad.cc | 3 ++- 3 files changed, 32 insertions(+), 26 deletions(-) diff --git a/configure.in b/configure.in index 476ebf7..4f03fe7 100644 --- a/configure.in +++ b/configure.in @@ -61,27 +61,7 @@ AC_SUBST(EXPAT_LIBS) dnl ====================== dnl Check for libwebsockets library dnl ====================== -tmp_CXXFLAGS="$CXXFLAGS" -tmp_CPPFLAGS="$CPPFLAGS" -tmp_CFLAGS="$CFLAGS" -tmp_LDFLAGS="$LDFLAGS" -tmp_LIBS="$LIBS" -CXXFLAGS="" -CPPFLAGS="" -CFLAGS="" -LDFLAGS="" -LIBS="" -AC_CHECK_HEADER(libwebsockets.h, , AC_MSG_ERROR([*** libwebsockets header file not found!])) -AC_CHECK_LIB(websockets, libwebsocket_create_context, , AC_MSG_ERROR([*** libwebsockets library not found!])) -LIBWEBSOCKETS_CFLAGS="$CXXFLAGS $CPPFLAGS $CFLAGS" -LIBWEBSOCKETS_LIBS="$LDFLAGS $LIBS" -CXXFLAGS="$tmp_CXXFLAGS" -CPPFLAGS="$tmp_CPPFLAGS" -CFLAGS="$tmp_CFLAGS" -LDFLAGS="$tmp_LDFLAGS" -LIBS="$tmp_LIBS" -AC_SUBST(LIBWEBSOCKETS_CFLAGS) -AC_SUBST(LIBWEBSOCKETS_LIBS) +PKG_CHECK_MODULES(LIBWEBSOCKETS, libwebsockets >= 1.0) AC_OUTPUT( Makefile diff --git a/src/http.cc b/src/http.cc index 6b14ed5..396e042 100644 --- a/src/http.cc +++ b/src/http.cc @@ -46,16 +46,25 @@ int callback_http(struct libwebsocket_context * context, // // add favicon later if(in && strcmp((const char *)in, "/favicon.ico") == 0) { - if(libwebsockets_serve_http_file(wsi, + if(libwebsockets_serve_http_file(context, wsi, LOCAL_RESOURCE_PATH"/favicon.ico", "image/x-icon")) DEBUG(httpd,"Failed to send favicon\n"); break; } + // css + if(in && strcmp((const char *)in, "/munia.css") == 0) { + if(libwebsockets_serve_http_file(context, wsi, + LOCAL_RESOURCE_PATH"/munia.css", + "text/css")) + DEBUG(httpd,"Failed to send css\n"); + break; + } + // script if(in && strcmp((const char *)in, "/proto.js") == 0) { - if(libwebsockets_serve_http_file(wsi, + if(libwebsockets_serve_http_file(context, wsi, LOCAL_RESOURCE_PATH"/proto.js", "text/javascript")) DEBUG(httpd,"Failed to send javascript\n"); @@ -63,16 +72,32 @@ int callback_http(struct libwebsocket_context * context, } if(in && strcmp((const char *)in, "/handler.js") == 0) { - if(libwebsockets_serve_http_file(wsi, + if(libwebsockets_serve_http_file(context, wsi, LOCAL_RESOURCE_PATH"/handler.js", "text/javascript")) DEBUG(httpd,"Failed to send javascript\n"); break; } + if(in && strcmp((const char *)in, "/view.js") == 0) { + if(libwebsockets_serve_http_file(context, wsi, + LOCAL_RESOURCE_PATH"/view.js", + "text/javascript")) + DEBUG(httpd,"Failed to send javascript\n"); + break; + } + + if(in && strcmp((const char *)in, "/task.js") == 0) { + if(libwebsockets_serve_http_file(context, wsi, + LOCAL_RESOURCE_PATH"/task.js", + "text/javascript")) + DEBUG(httpd,"Failed to send javascript\n"); + break; + } + /* send the script... when it runs it'll start websockets */ - if(libwebsockets_serve_http_file(wsi, + if(libwebsockets_serve_http_file(context, wsi, LOCAL_RESOURCE_PATH"/munia.html", "text/html")) DEBUG(httpd,"Failed to send HTTP file\n"); diff --git a/src/muniad.cc b/src/muniad.cc index 3ea7d6c..ebf0870 100644 --- a/src/muniad.cc +++ b/src/muniad.cc @@ -123,7 +123,8 @@ int main(int argc, char **argv) context = libwebsocket_create_context(port, interface, protocols, libwebsocket_internal_extensions, - cert_path, key_path, -1, -1, opts); + cert_path, key_path, "", -1, -1, opts, + NULL); if (context == NULL) { fprintf(stderr, "libwebsocket init failed\n"); return -1; -- cgit v1.2.3