Don't pass req in open handler
This commit is contained in:
@@ -16,7 +16,7 @@ int main() {
|
||||
.idleTimeout = 10,
|
||||
.maxBackpressure = 1 * 1024 * 1204,
|
||||
/* Handlers */
|
||||
.open = [](auto *ws, auto *req) {
|
||||
.open = [](auto *ws) {
|
||||
/* Let's make every connection subscribe to the "broadcast" topic */
|
||||
ws->subscribe("broadcast");
|
||||
},
|
||||
|
||||
@@ -84,7 +84,7 @@ int main() {
|
||||
|
||||
|
||||
},
|
||||
.open = [](auto *ws, auto *req) {
|
||||
.open = [](auto *ws) {
|
||||
/* Open event here, you may access ws->getUserData() which points to a PerSocketData struct */
|
||||
std::cout << "Something is: " << static_cast<PerSocketData *>(ws->getUserData())->something << std::endl;
|
||||
},
|
||||
|
||||
@@ -22,7 +22,7 @@ int main() {
|
||||
.idleTimeout = 10,
|
||||
.maxBackpressure = 1 * 1024 * 1204,
|
||||
/* Handlers */
|
||||
.open = [](auto *ws, auto *req) {
|
||||
.open = [](auto *ws) {
|
||||
|
||||
},
|
||||
.message = [](auto *ws, std::string_view message, uWS::OpCode opCode) {
|
||||
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
int idleTimeout = 120;
|
||||
int maxBackpressure = 1 * 1024 * 1024;
|
||||
fu2::unique_function<void(HttpResponse<SSL> *, HttpRequest *, struct us_socket_context_t *)> upgrade = nullptr;
|
||||
fu2::unique_function<void(uWS::WebSocket<SSL, true> *, HttpRequest *)> open = nullptr;
|
||||
fu2::unique_function<void(uWS::WebSocket<SSL, true> *)> open = nullptr;
|
||||
fu2::unique_function<void(uWS::WebSocket<SSL, true> *, std::string_view, uWS::OpCode)> message = nullptr;
|
||||
fu2::unique_function<void(uWS::WebSocket<SSL, true> *)> drain = nullptr;
|
||||
fu2::unique_function<void(uWS::WebSocket<SSL, true> *)> ping = nullptr;
|
||||
|
||||
+1
-1
@@ -270,7 +270,7 @@ public:
|
||||
|
||||
/* Emit open event and start the timeout */
|
||||
if (webSocketContextData->openHandler) {
|
||||
webSocketContextData->openHandler(webSocket, /*req*/ nullptr);
|
||||
webSocketContextData->openHandler(webSocket);
|
||||
}
|
||||
|
||||
// if we weren't corked then uncork here! otherwise we were called from httpContext!
|
||||
|
||||
@@ -34,7 +34,7 @@ template <bool, bool> struct WebSocket;
|
||||
template <bool SSL>
|
||||
struct WebSocketContextData {
|
||||
/* The callbacks for this context */
|
||||
fu2::unique_function<void(uWS::WebSocket<SSL, true> *, HttpRequest *)> openHandler = nullptr;
|
||||
fu2::unique_function<void(uWS::WebSocket<SSL, true> *)> openHandler = nullptr;
|
||||
fu2::unique_function<void(WebSocket<SSL, true> *, std::string_view, uWS::OpCode)> messageHandler = nullptr;
|
||||
fu2::unique_function<void(WebSocket<SSL, true> *)> drainHandler = nullptr;
|
||||
fu2::unique_function<void(WebSocket<SSL, true> *, int, std::string_view)> closeHandler = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user