Refactoring into separate .hpp and .cpp files.
This commit is contained in:
+2
-7
@@ -1,17 +1,12 @@
|
||||
#define EASYWSCLIENT_COMPILATION_UNIT
|
||||
#include "easywsclient.hpp"
|
||||
#include "easywsclient.cpp" // <-- include only if you don't want compile separately
|
||||
#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()
|
||||
@@ -21,7 +16,7 @@ int main()
|
||||
assert(ws);
|
||||
ws->send("goodbye");
|
||||
ws->send("hello");
|
||||
while (message != "world") {
|
||||
while (true) {
|
||||
ws->poll();
|
||||
ws->dispatch(handle_message);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user