Got first version working. Can connect, send, and receive.

This commit is contained in:
David Baird
2012-08-19 22:46:33 -06:00
parent 5e5bc69860
commit b94fec0873
5 changed files with 448 additions and 1 deletions
+25
View File
@@ -0,0 +1,25 @@
// Compile with:
// g++ -std=gnu++0x example-client-cpp11.cpp -o example-client-cpp11
#include "easywsclient.hpp"
#include <assert.h>
#include <stdio.h>
#include <string>
int main()
{
using easywsclient::WebSocket;
WebSocket::pointer ws = WebSocket::from_url("ws://localhost:8126/foo");
assert(ws);
ws->send("goodbye");
ws->send("hello");
while (true) {
std::string message;
ws->poll();
ws->dispatch([&message](const std::string & message_) {
printf(">>> %s\n", message_.c_str());
message = message_;
});
if (message == "world") { break; }
}
return 0;
}