Skip to content

Commit ca8d620

Browse files
committed
Add some initial client stuff
1 parent c8229b5 commit ca8d620

3 files changed

Lines changed: 45 additions & 1 deletion

File tree

build.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ int main(int argc, char **argv) {
99
char *CXX = strcpy(calloc(1024, 1), or_else(getenv("CXX"), "g++"));
1010
char *EXEC_SUFFIX = strcpy(calloc(1024, 1), maybe(getenv("EXEC_SUFFIX")));
1111

12-
char *EXAMPLE_FILES[] = {"Http3Server", "Broadcast", "HelloWorld", "Crc32", "ServerName",
12+
char *EXAMPLE_FILES[] = {"Client", "Http3Server", "Broadcast", "HelloWorld", "Crc32", "ServerName",
1313
"EchoServer", "BroadcastingEchoServer", "UpgradeSync", "UpgradeAsync"};
1414

1515
strcat(CXXFLAGS, " -O3 -Wpedantic -Wall -Wextra -Wsign-conversion -Wconversion -std=c++2a -Isrc -IuSockets/src");

examples/Client.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include "Client.h"
2+
#include <iostream>
3+
4+
int main() {
5+
uWS::Client({
6+
.open = [](/*auto *ws*/) {
7+
std::cout << "Hello and welcome to client" << std::endl;
8+
},
9+
.message = [](/*auto *ws, auto message*/) {
10+
11+
},
12+
.close = [](/*auto *ws*/) {
13+
std::cout << "bye" << std::endl;
14+
}
15+
}).connect("ws://localhost:3000").run();
16+
}

src/Client.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include "MoveOnlyFunction.h"
2+
3+
namespace uWS {
4+
5+
struct WebSocketClientBehavior {
6+
MoveOnlyFunction<void()> open;
7+
MoveOnlyFunction<void()> message;
8+
MoveOnlyFunction<void()> close;
9+
};
10+
11+
struct Client {
12+
13+
Client(WebSocketClientBehavior &&behavior) {
14+
15+
}
16+
17+
Client &&connect(std::string url) {
18+
19+
return std::move(*this);
20+
}
21+
22+
void run() {
23+
24+
}
25+
26+
};
27+
28+
}

0 commit comments

Comments
 (0)