diff --git a/README.coding b/README.coding index dfe6a414..caec22f6 100644 --- a/README.coding +++ b/README.coding @@ -136,3 +136,18 @@ appear in the callback for protocol 0 and allow interface code to manage socket descriptors in other poll loops. +Using with in c++ apps +---------------------- + +The library is ready for use by C++ apps. You can get started quickly by +copying the test server + +$ cp test-server/test-server.c test.cpp + +and building it in C++ like this + +$ g++ -DINSTALL_DATADIR=\"/usr/share\" -ocpptest test.cpp -lwebsockets + +INSTALL_DATADIR is only needed because the test server uses it as shipped, if +you remove the references to it in your app you don't need to define it on +the g++ line either. diff --git a/test-server/test-server.c b/test-server/test-server.c index 5d06fa05..307f6297 100644 --- a/test-server/test-server.c +++ b/test-server/test-server.c @@ -107,7 +107,7 @@ static int callback_http(struct libwebsocket_context *context, case LWS_CALLBACK_HTTP: for (n = 0; n < (sizeof(whitelist) / sizeof(whitelist[0]) - 1); n++) - if (in && strcmp(in, whitelist[n].urlpath) == 0) + if (in && strcmp((const char *)in, whitelist[n].urlpath) == 0) break; sprintf(buf, LOCAL_RESOURCE_PATH"%s", whitelist[n].urlpath); @@ -260,7 +260,7 @@ callback_dumb_increment(struct libwebsocket_context *context, unsigned char buf[LWS_SEND_BUFFER_PRE_PADDING + 512 + LWS_SEND_BUFFER_POST_PADDING]; unsigned char *p = &buf[LWS_SEND_BUFFER_PRE_PADDING]; - struct per_session_data__dumb_increment *pss = user; + struct per_session_data__dumb_increment *pss = (struct per_session_data__dumb_increment *)user; switch (reason) { @@ -288,7 +288,7 @@ callback_dumb_increment(struct libwebsocket_context *context, // fprintf(stderr, "rx %d\n", (int)len); if (len < 6) break; - if (strcmp(in, "reset\n") == 0) + if (strcmp((const char *)in, "reset\n") == 0) pss->number = 0; break; /* @@ -337,7 +337,7 @@ callback_lws_mirror(struct libwebsocket_context *context, void *user, void *in, size_t len) { int n; - struct per_session_data__lws_mirror *pss = user; + struct per_session_data__lws_mirror *pss = (struct per_session_data__lws_mirror *)user; switch (reason) {