From 526a9ad6cdc0299b95ef9c8d337ce99d2cac120a Mon Sep 17 00:00:00 2001 From: Alex Hultman Date: Wed, 30 Nov 2022 22:21:25 +0100 Subject: [PATCH] Fix recent build --- examples/Client.cpp | 26 +++++++++++++++----------- src/Client.h | 28 ---------------------------- src/ClientApp.h | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 39 deletions(-) delete mode 100644 src/Client.h create mode 100644 src/ClientApp.h diff --git a/examples/Client.cpp b/examples/Client.cpp index d5f3f4f..9f2d338 100644 --- a/examples/Client.cpp +++ b/examples/Client.cpp @@ -1,16 +1,20 @@ -#include "Client.h" +#include "ClientApp.h" #include int main() { - uWS::Client({ - .open = [](/*auto *ws*/) { - std::cout << "Hello and welcome to client" << std::endl; - }, - .message = [](/*auto *ws, auto message*/) { + uWS::ClientApp app({ + .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(); + }, + .close = [](/*auto *ws*/) { + std::cout << "bye" << std::endl; + } + }); + + app.connect("ws://localhost:3000", "protocol"); + + app.run(); } \ No newline at end of file diff --git a/src/Client.h b/src/Client.h deleted file mode 100644 index 0fe6df4..0000000 --- a/src/Client.h +++ /dev/null @@ -1,28 +0,0 @@ -#include "MoveOnlyFunction.h" - -namespace uWS { - - struct WebSocketClientBehavior { - MoveOnlyFunction open; - MoveOnlyFunction message; - MoveOnlyFunction close; - }; - - struct Client { - - Client(WebSocketClientBehavior &&behavior) { - - } - - Client &&connect(std::string url) { - - return std::move(*this); - } - - void run() { - - } - - }; - -} \ No newline at end of file diff --git a/src/ClientApp.h b/src/ClientApp.h new file mode 100644 index 0000000..d869637 --- /dev/null +++ b/src/ClientApp.h @@ -0,0 +1,36 @@ +#include "MoveOnlyFunction.h" +#include "WebSocketContext.h" +#include + +namespace uWS { + + struct WebSocketClientBehavior { + MoveOnlyFunction open; + MoveOnlyFunction message; + MoveOnlyFunction close; + //MoveOnlyFunction failed; + + }; + + struct ClientApp { + + WebSocketContext<0, false, int> *webSocketContext; + // behöver ett nytt http context med minimal klient, som slår om till den riktiga websocketcontext + // om samma storlek på httpsocket och websocket blir det enkel övergång + + ClientApp(WebSocketClientBehavior &&behavior) { + //webSocketContext = WebSocketContext<0, false, int>::create(); + } + + ClientApp &&connect(std::string url, std::string protocol = "") { + + return std::move(*this); + } + + void run() { + + } + + }; + +} \ No newline at end of file