From f64a9b8c815fb075ba5bba4a187822e19f553799 Mon Sep 17 00:00:00 2001 From: bel Date: Thu, 28 Aug 2014 23:28:16 +0200 Subject: [PATCH] Add Visual Studio project for websocket_client example --- VS2012/civetweb.sln | 12 ++ .../ex_websocket_client.vcxproj | 157 ++++++++++++++++++ .../ex_websocket_client.vcxproj.filters | 30 ++++ examples/websocket_client/websocket_client.c | 12 +- 4 files changed, 207 insertions(+), 4 deletions(-) create mode 100644 VS2012/ex_websocket_client/ex_websocket_client.vcxproj create mode 100644 VS2012/ex_websocket_client/ex_websocket_client.vcxproj.filters diff --git a/VS2012/civetweb.sln b/VS2012/civetweb.sln index a2d6b8a1..88b9e807 100644 --- a/VS2012/civetweb.sln +++ b/VS2012/civetweb.sln @@ -15,6 +15,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ex_embedded_c", "ex_embedde EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unit_test", "unit_test\unit_test.vcxproj", "{1AC4A7A6-0100-4287-97F4-B95807BE5607}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ex_websocket_client", "ex_websocket_client\ex_websocket_client.vcxproj", "{58B93E94-7766-435E-93AE-42A2FB5D99B2}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Mixed Platforms = Debug|Mixed Platforms @@ -107,6 +109,16 @@ Global {1AC4A7A6-0100-4287-97F4-B95807BE5607}.Release|Win32.ActiveCfg = Release|Win32 {1AC4A7A6-0100-4287-97F4-B95807BE5607}.Release|Win32.Build.0 = Release|Win32 {1AC4A7A6-0100-4287-97F4-B95807BE5607}.Release|x64.ActiveCfg = Release|Win32 + {58B93E94-7766-435E-93AE-42A2FB5D99B2}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {58B93E94-7766-435E-93AE-42A2FB5D99B2}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {58B93E94-7766-435E-93AE-42A2FB5D99B2}.Debug|Win32.ActiveCfg = Debug|Win32 + {58B93E94-7766-435E-93AE-42A2FB5D99B2}.Debug|Win32.Build.0 = Debug|Win32 + {58B93E94-7766-435E-93AE-42A2FB5D99B2}.Debug|x64.ActiveCfg = Debug|Win32 + {58B93E94-7766-435E-93AE-42A2FB5D99B2}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {58B93E94-7766-435E-93AE-42A2FB5D99B2}.Release|Mixed Platforms.Build.0 = Release|Win32 + {58B93E94-7766-435E-93AE-42A2FB5D99B2}.Release|Win32.ActiveCfg = Release|Win32 + {58B93E94-7766-435E-93AE-42A2FB5D99B2}.Release|Win32.Build.0 = Release|Win32 + {58B93E94-7766-435E-93AE-42A2FB5D99B2}.Release|x64.ActiveCfg = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/VS2012/ex_websocket_client/ex_websocket_client.vcxproj b/VS2012/ex_websocket_client/ex_websocket_client.vcxproj new file mode 100644 index 00000000..15842d7f --- /dev/null +++ b/VS2012/ex_websocket_client/ex_websocket_client.vcxproj @@ -0,0 +1,157 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {58B93E94-7766-435E-93AE-42A2FB5D99B2} + Win32Proj + ex_websocket_client + + + + Application + true + Unicode + + + Application + true + v110 + Unicode + + + Application + false + true + Unicode + + + Application + false + v110 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(SolutionDir)\$(Configuration)\$(Platform)\ + + + true + $(SolutionDir)\$(Configuration)\$(Platform)\ + + + false + $(SolutionDir)\$(Configuration)\$(Platform)\ + + + false + $(SolutionDir)\$(Configuration)\$(Platform)\ + + + + + + Level3 + Disabled + USE_WEBSOCKET;WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + $(ProjectDir)..\..\include;%(AdditionalIncludeDirectories) + + + Console + true + + + + + + + Level3 + Disabled + USE_WEBSOCKET;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(ProjectDir)..\..\include;%(AdditionalIncludeDirectories) + + + Console + true + + + + + Level3 + + + MaxSpeed + true + true + USE_WEBSOCKET;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(ProjectDir)..\..\include;%(AdditionalIncludeDirectories) + + + Console + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + USE_WEBSOCKET;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + $(ProjectDir)..\..\include;%(AdditionalIncludeDirectories) + + + Console + true + true + true + + + + + + + + + + + + + \ No newline at end of file diff --git a/VS2012/ex_websocket_client/ex_websocket_client.vcxproj.filters b/VS2012/ex_websocket_client/ex_websocket_client.vcxproj.filters new file mode 100644 index 00000000..c91ce3eb --- /dev/null +++ b/VS2012/ex_websocket_client/ex_websocket_client.vcxproj.filters @@ -0,0 +1,30 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/examples/websocket_client/websocket_client.c b/examples/websocket_client/websocket_client.c index 294c14dd..ae7110f8 100644 --- a/examples/websocket_client/websocket_client.c +++ b/examples/websocket_client/websocket_client.c @@ -7,6 +7,7 @@ // Simple example program on how to use websocket client embedded C interface. #ifdef _WIN32 #include +#define sleep(x) Sleep(1000*(x)) #else #include #endif @@ -20,7 +21,9 @@ static int websocket_data_handler(struct mg_connection *conn, int flags, char *data, size_t data_len) { - printf("From server: %s\r\n", data); + printf("From server: "); + fwrite(data, 1, data_len, stdout); + printf("\r\n"); return 1; } @@ -34,16 +37,17 @@ int main(int argc, char *argv[]) }; struct mg_callbacks callbacks; struct mg_context *ctx; + struct mg_connection* newconn; + char ebuf[100]; memset(&callbacks, 0, sizeof(callbacks)); ctx = mg_start(&callbacks, 0, options); - char ebuf[100]; - struct mg_connection* newconn = mg_websocket_client_connect("echo.websocket.org", 443, 1, + newconn = mg_websocket_client_connect("echo.websocket.org", 443, 1, ebuf, sizeof(ebuf), "/", "http://websocket.org",websocket_data_handler); - if(newconn == NULL) + if (newconn == NULL) { printf("Error: %s", ebuf); return 1;