How to get header msg from on_message #1097
|
Hello, I want to get header msg from on_message, how do it? Thanks |
Replies: 3 comments
|
Hi Alex, this sounds like the question that is bugging me right now. In the websocket case, is there a way to associate anything from the .upgrade handler to the .open handler. In other words, is there anything in the WebSocket<> pointer that refers to the previous upgrade request? I hope my question is clear enough thx for your time |
|
The UpgradeSync example shows this: https://github.com/uNetworking/uWebSockets/blob/master/examples/UpgradeSync.cpp You pass a copy of your PerSocketData struct via the res->upgrade call. But, because it is sync, you can also just use a global thread_local variable to temporary point to something in the request. This is not very elegant but it does work and removes the need to keep more than necessary in your PerSocketData. |
|
thx Alex, I was soo blind :-( |
The UpgradeSync example shows this: https://github.com/uNetworking/uWebSockets/blob/master/examples/UpgradeSync.cpp
You pass a copy of your PerSocketData struct via the res->upgrade call. But, because it is sync, you can also just use a global thread_local variable to temporary point to something in the request. This is not very elegant but it does work and removes the need to keep more than necessary in your PerSocketData.