You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[question]Can messages be send to client outside main thread? #94
Hi i am planning to run a websocket server in a separate thread from my main program. I am new to mutex, lock and unique_lock. I have saved the client pointer from 'onmessage' function. Can i safely use ws_sendframe from my main program using this pointer.
Hi @habi498,
Yes, you can.
Just be careful if your client disconnects... since the list of clients in wsServer is static, reusing the pointer of a connection that has already been closed may result in sending a message to a client that does not exist, or even to another client.
Just be careful if your client disconnects... since the list of clients in wsServer is static, reusing the pointer of a connection that has already been closed may result in sending a message to a client that does not exist, or even to another client.
Since this is no longer a issue (thanks to PR #96), I'm going to close this. Please feel free re-open it or create new issues if you feel the need =).
Activity
Theldus commentedon Aug 21, 2024
Hi @habi498,
Yes, you can.
Just be careful if your client disconnects... since the list of clients in wsServer is static, reusing the pointer of a connection that has already been closed may result in sending a message to a client that does not exist, or even to another client.
habi498 commentedon Aug 22, 2024
Hi Theldus,
Thanks for reply. Also i will take care not to use client pointer after they disconnect
Theldus commentedon Sep 5, 2024
Since this is no longer a issue (thanks to PR #96), I'm going to close this. Please feel free re-open it or create new issues if you feel the need =).