-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Description
I want to implement a client:
`#include <uwebsockets/App.h>
#include
#include
using namespace std;
class UserData
{
};
int main() {
string url = "ws://localhost:9001";
uWS::App app;
uWS::App::WebSocketBehavior<UserData> behavior;
//auto behavior = uWS::App::WebSocketBehavior<UserData>();
behavior.open = [](uWS::WebSocket<false, true, UserData>* ws, uWS::HttpRequest req) {
std::cout << "Connected to the server!" << std::endl;
ws->send("Hello from the client!");
};
behavior.message = [](uWS::WebSocket<false, true, UserData>* ws, std::string_view message, uWS::OpCode opCode) {
std::cout << "Received message: " << message << std::endl;
};
behavior.close = [](uWS::WebSocket<false, true, UserData>* ws, int code, std::string_view message) {
std::cout << "Disconnected from the server!" << std::endl;
};
behavior.ping = [](uWS::WebSocket<false, true, UserData>* ws, std::string_view message) {
std::cout << "Received ping: " << message << std::endl;
};
behavior.pong = [](uWS::WebSocket<false, true, UserData>* ws, std::string_view message) {
std::cout << "Received pong: " << message << std::endl;
};
//app.ws<UserData>(url, std::forward<decltype(behavior)>(behavior));
app.ws<UserData>(url, std::move(behavior));
//app.ws<UserData>(url, behavior);
app.run();
return 0;
}`
But this code reported an error in VS2022 with C++20:
error C2440: “”: cannot convert from “initializer list” to “ofats::any_invocable<void (uWS::WebSocket<false,true,UserData> *)>”
Help me please
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels