diff --git a/VS2012/civetweb/civetweb.vcxproj b/VS2012/civetweb/civetweb.vcxproj index 91d81533..8dfcea71 100644 --- a/VS2012/civetweb/civetweb.vcxproj +++ b/VS2012/civetweb/civetweb.vcxproj @@ -39,7 +39,7 @@ Application false - v110_xp + v100 true MultiByte diff --git a/VS2012/ex_embed_cpp/ex_embed_cpp.vcxproj b/VS2012/ex_embed_cpp/ex_embed_cpp.vcxproj index 09ff3461..3dd0e8a6 100644 --- a/VS2012/ex_embed_cpp/ex_embed_cpp.vcxproj +++ b/VS2012/ex_embed_cpp/ex_embed_cpp.vcxproj @@ -39,7 +39,7 @@ Application false - v110_xp + v100 true MultiByte diff --git a/VS2012/ex_embedded_c/ex_embedded_c.vcxproj b/VS2012/ex_embedded_c/ex_embedded_c.vcxproj index ee7b298a..9dd5b8f7 100644 --- a/VS2012/ex_embedded_c/ex_embedded_c.vcxproj +++ b/VS2012/ex_embedded_c/ex_embedded_c.vcxproj @@ -46,7 +46,7 @@ Application false - v110_xp + v100 true MultiByte diff --git a/VS2012/ex_websocket/ex_websocket.vcxproj b/VS2012/ex_websocket/ex_websocket.vcxproj index 9ce2ae38..30518629 100644 --- a/VS2012/ex_websocket/ex_websocket.vcxproj +++ b/VS2012/ex_websocket/ex_websocket.vcxproj @@ -40,6 +40,7 @@ false true MultiByte + v100 Application @@ -116,7 +117,7 @@ MaxSpeed true true - USE_WEBSOCKET;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + USE_WEBSOCKET;WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ProjectDir)..\..\include;%(AdditionalIncludeDirectories) diff --git a/VS2012/ex_websocket_client/ex_websocket_client.vcxproj b/VS2012/ex_websocket_client/ex_websocket_client.vcxproj index 8d385780..f2e43cba 100644 --- a/VS2012/ex_websocket_client/ex_websocket_client.vcxproj +++ b/VS2012/ex_websocket_client/ex_websocket_client.vcxproj @@ -40,6 +40,7 @@ false true MultiByte + v100 Application @@ -116,7 +117,7 @@ MaxSpeed true true - USE_WEBSOCKET;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + USE_WEBSOCKET;WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) $(ProjectDir)..\..\include;%(AdditionalIncludeDirectories) diff --git a/VS2012/unit_test/unit_test.vcxproj b/VS2012/unit_test/unit_test.vcxproj index 20d86974..db6bc180 100644 --- a/VS2012/unit_test/unit_test.vcxproj +++ b/VS2012/unit_test/unit_test.vcxproj @@ -26,6 +26,7 @@ false true MultiByte + v100 diff --git a/VS2012/upload/upload.vcxproj b/VS2012/upload/upload.vcxproj index f775f48c..09292e51 100644 --- a/VS2012/upload/upload.vcxproj +++ b/VS2012/upload/upload.vcxproj @@ -46,7 +46,7 @@ Application false - v110_xp + v100 true MultiByte diff --git a/examples/embedded_c/embedded_c.c b/examples/embedded_c/embedded_c.c index 8d5c313b..f88440fc 100644 --- a/examples/embedded_c/embedded_c.c +++ b/examples/embedded_c/embedded_c.c @@ -132,14 +132,13 @@ int WebSocketConnectHandler(const struct mg_connection * conn, void *cbdata) return reject; } -void WebSocketReadyHandler(const struct mg_connection * conn, void *cbdata) +void WebSocketReadyHandler(struct mg_connection * conn, void *cbdata) { - struct mg_context *ctx = mg_get_context((struct mg_connection *) /* TODO: check const_casts */ conn); + struct mg_context *ctx = mg_get_context(conn); int i; const char * text = "Hello from the websocket ready handler"; - /* TODO: check "const struct mg_connection *" vs "struct mg_connection *" everywhere */ - mg_websocket_write((struct mg_connection *)conn, WEBSOCKET_OPCODE_TEXT, text, strlen(text)); + mg_websocket_write(conn, WEBSOCKET_OPCODE_TEXT, text, strlen(text)); fprintf(stdout, "Client added to the set of webserver connections\r\n\r\n"); mg_lock_context(ctx); for (i=0; ictx); } @@ -5755,7 +5755,7 @@ static void read_websocket(struct mg_connection *conn, mg_websocket_data_handler The original websocket upgrade request is never removed, so the queue begins after it. */ unsigned char *buf = (unsigned char *) conn->buf + conn->request_len; - int n, error; + int n, error, exit_by_callback; /* body_len is the length of the entire queue in bytes len is the length of the current message @@ -5867,6 +5867,7 @@ static void read_websocket(struct mg_connection *conn, mg_websocket_data_handler /* Exit the loop if callback signalled to exit, or "connection close" opcode received. */ + exit_by_callback = 0; if ((ws_data_handler != NULL && #ifdef USE_LUA (conn->lua_websocket_state == NULL) && @@ -5876,13 +5877,19 @@ static void read_websocket(struct mg_connection *conn, mg_websocket_data_handler (conn->lua_websocket_state && !lua_websocket_data(conn, conn->lua_websocket_state, mop, data, data_len)) || #endif - (mop & 0xf) == WEBSOCKET_OPCODE_CONNECTION_CLOSE) { /* Opcode == 8, connection close */ - break; + 0) { + exit_by_callback = 1; } if (data != mem) { mg_free(data); } + + if (exit_by_callback || ((mop & 0xf) == WEBSOCKET_OPCODE_CONNECTION_CLOSE)) { + /* Opcode == 8, connection close */ + break; + } + /* Not breaking the loop, process next websocket frame. */ } else { /* Read from the socket into the next available location in the @@ -5952,9 +5959,8 @@ static void handle_websocket_request(struct mg_connection *conn, const char *version = mg_get_header(conn, "Sec-WebSocket-Version"); int lua_websock = 0; -#ifndef USE_LUA +#if !defined(USE_LUA) (void)path; - (void)is_callback_resource; #endif /* Step 1: Check websocket protocol version. */ @@ -5974,7 +5980,7 @@ static void handle_websocket_request(struct mg_connection *conn, } } -#ifdef USE_LUA +#if defined(USE_LUA) /* Step 3: No callback. Check if Lua is responsible. */ else { /* Step 3.1: Check if Lua is responsible. */ @@ -6011,11 +6017,13 @@ static void handle_websocket_request(struct mg_connection *conn, if (ws_ready_handler != NULL) { ws_ready_handler(conn, cbData); } +#if defined(USE_LUA) } else if (lua_websock) { if (!lua_websocket_ready(conn, conn->lua_websocket_state)) { /* the ready handler returned false */ return; } +#endif } /* Step 7: Enter the read loop */ diff --git a/testutils/testclient/testclient.vcxproj b/testutils/testclient/testclient.vcxproj index b6d889b2..5b1fd2b4 100644 --- a/testutils/testclient/testclient.vcxproj +++ b/testutils/testclient/testclient.vcxproj @@ -26,6 +26,7 @@ false true MultiByte + v100 diff --git a/testutils/testclient_chunked_linux/testclient2.vcxproj b/testutils/testclient_chunked_linux/testclient2.vcxproj index 29abac0a..42a2908a 100644 --- a/testutils/testclient_chunked_linux/testclient2.vcxproj +++ b/testutils/testclient_chunked_linux/testclient2.vcxproj @@ -26,6 +26,7 @@ false true MultiByte + v100