easywsclient for Windows
Revised a source file to be able to compile it in Linux and Windows. Revised a description error of the include sentence for Windows. followed the modification of the original version. preparing for pull request. preparing for pull request. Convert tabs to spaces. Add delete ws; to 'example-client.cpp'. try2 try4
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
#include "easywsclient.hpp"
|
||||
//#include "easywsclient.cpp" // <-- include only if you don't want compile separately
|
||||
#ifdef _WIN32
|
||||
#pragma comment( lib, "ws2_32" )
|
||||
#include <WinSock2.h>
|
||||
#endif
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
@@ -15,6 +19,17 @@ void handle_message(const std::string & message)
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
INT rc;
|
||||
WSADATA wsaData;
|
||||
|
||||
rc = WSAStartup(MAKEWORD(2, 2), &wsaData);
|
||||
if (rc) {
|
||||
printf("WSAStartup Failed.\n");
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
ws = WebSocket::from_url("ws://localhost:8126/foo");
|
||||
assert(ws);
|
||||
ws->send("goodbye");
|
||||
@@ -24,5 +39,8 @@ int main()
|
||||
ws->dispatch(handle_message);
|
||||
}
|
||||
delete ws;
|
||||
#ifdef _WIN32
|
||||
WSACleanup();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user