Add EchoServer example

This commit is contained in:
Alex Hultman
2018-12-21 03:17:15 +01:00
parent 3e75936387
commit 2a1fc55b58
2 changed files with 38 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
#include "App.h"
int main() {
/* Very simple WebSocket echo server */
uWS::App().ws<void>("/*", {
/*.compression = */true,
/*.maxPayloadLength*/
/*.open = */[](auto *ws, auto *req) {
},
/*.message = */[](auto *ws, std::string_view message, uWS::OpCode opCode) {
ws->send(message, opCode);
}
/*.drain = []() {
},
.ping = []() {
},
.pong = []() {
},
.close = []() {
}*/
}).listen(9001, [](auto *token) {
if (token) {
std::cout << "Listening on port " << 9001 << std::endl;
}
}).run();
}