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
+28
View File
@@ -0,0 +1,28 @@
#include "easywsclient.hpp"
#include <assert.h>
#include <stdio.h>
#include <string>
// N.B. A real application should abuse a global variable like this...
// (gets messy if threads are involved)
std::string message;
void handle_message(const std::string & message)
{
printf(">>> %s\n", message.c_str());
::message = message;
}
int main()
{
using easywsclient::WebSocket;
WebSocket::pointer ws = WebSocket::from_url("ws://localhost:8126/foo");
assert(ws);
ws->send("goodbye");
ws->send("hello");
while (message != "world") {
ws->poll();
ws->dispatch(handle_message);
}
return 0;
}