Take opCode in main.cpp
This commit is contained in:
+20
-2
@@ -7,12 +7,30 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
// do websockets here
|
// do websockets here
|
||||||
|
|
||||||
|
/*
|
||||||
|
uWS::App().ws("/*", {
|
||||||
|
.open = []() {
|
||||||
|
|
||||||
|
},
|
||||||
|
.message = []() {
|
||||||
|
|
||||||
|
},
|
||||||
|
.drain = []() {
|
||||||
|
|
||||||
|
},
|
||||||
|
.close = []() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}).listen().run();*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
uWS::App().get("/hello", [](auto *res, auto *req) {
|
uWS::App().get("/hello", [](auto *res, auto *req) {
|
||||||
res->end("Hello HTTP!");
|
res->end("Hello HTTP!");
|
||||||
}).ws("/*", [](auto *ws, auto *req) {
|
}).ws("/*", [](auto *ws, auto *req) {
|
||||||
std::cout << "WebSocket conntected to URL: " << req->getUrl() << std::endl;
|
std::cout << "WebSocket conntected to URL: " << req->getUrl() << std::endl;
|
||||||
}, [](auto *ws, std::string_view message) {
|
}, [](auto *ws, std::string_view message, uWS::OpCode opCode) {
|
||||||
ws->send(message);
|
ws->send(message, opCode);
|
||||||
}).listen(3000, [](auto *token) {
|
}).listen(3000, [](auto *token) {
|
||||||
if (token) {
|
if (token) {
|
||||||
std::cout << "Listening on port " << 3000 << std::endl;
|
std::cout << "Listening on port " << 3000 << std::endl;
|
||||||
|
|||||||
Reference in New Issue
Block a user