Add some initial client stuff

This commit is contained in:
Alex Hultman
2022-11-26 07:36:01 +01:00
parent c8229b5781
commit ca8d620268
3 changed files with 45 additions and 1 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ int main(int argc, char **argv) {
char *CXX = strcpy(calloc(1024, 1), or_else(getenv("CXX"), "g++"));
char *EXEC_SUFFIX = strcpy(calloc(1024, 1), maybe(getenv("EXEC_SUFFIX")));
char *EXAMPLE_FILES[] = {"Http3Server", "Broadcast", "HelloWorld", "Crc32", "ServerName",
char *EXAMPLE_FILES[] = {"Client", "Http3Server", "Broadcast", "HelloWorld", "Crc32", "ServerName",
"EchoServer", "BroadcastingEchoServer", "UpgradeSync", "UpgradeAsync"};
strcat(CXXFLAGS, " -O3 -Wpedantic -Wall -Wextra -Wsign-conversion -Wconversion -std=c++2a -Isrc -IuSockets/src");
+16
View File
@@ -0,0 +1,16 @@
#include "Client.h"
#include <iostream>
int main() {
uWS::Client({
.open = [](/*auto *ws*/) {
std::cout << "Hello and welcome to client" << std::endl;
},
.message = [](/*auto *ws, auto message*/) {
},
.close = [](/*auto *ws*/) {
std::cout << "bye" << std::endl;
}
}).connect("ws://localhost:3000").run();
}
+28
View File
@@ -0,0 +1,28 @@
#include "MoveOnlyFunction.h"
namespace uWS {
struct WebSocketClientBehavior {
MoveOnlyFunction<void()> open;
MoveOnlyFunction<void()> message;
MoveOnlyFunction<void()> close;
};
struct Client {
Client(WebSocketClientBehavior &&behavior) {
}
Client &&connect(std::string url) {
return std::move(*this);
}
void run() {
}
};
}