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
For now I haven't found a way to match a Websocket& with the std::set<std::shared_ptr<WebSocket>>,
from the client message callback void(std::shared_ptr<ConnectionState>, WebSocket&, const WebSocketMessagePtr&),
and get clients std::set<std::shared_ptr<WebSocket>> getClients() respectively. I can not tell the clients from getClients from each other, this is necessary when you want to send message asynchronously.
For now the only workaround I know is address comparison, which is not a real solution. Since there is an unegligible chance that a newly allocated Websocket object takes the place of a previously free-d one (in the heap), so they'll have the same address.
I guess this can be done by changing the OnClientMessageCallback to std::function<void(std::shared_ptr<ConnectionState>, std::shared_ptr<WebSocket>, const WebSocketMessagePtr&)> (replace reference with shared_ptr). The shared_ptr can be converted to a weak_ptr for long-term storage. This is a breaking change, though.
The text was updated successfully, but these errors were encountered:
For now I haven't found a way to match a
Websocket&
with thestd::set<std::shared_ptr<WebSocket>>
,from the client message callback
void(std::shared_ptr<ConnectionState>, WebSocket&, const WebSocketMessagePtr&)
,and get clients
std::set<std::shared_ptr<WebSocket>> getClients()
respectively. I can not tell the clients fromgetClients
from each other, this is necessary when you want to send message asynchronously.For now the only workaround I know is address comparison, which is not a real solution. Since there is an unegligible chance that a newly allocated
Websocket
object takes the place of a previously free-d one (in the heap), so they'll have the same address.I guess this can be done by changing the
OnClientMessageCallback
tostd::function<void(std::shared_ptr<ConnectionState>, std::shared_ptr<WebSocket>, const WebSocketMessagePtr&)>
(replace reference with shared_ptr). Theshared_ptr
can be converted to aweak_ptr
for long-term storage. This is a breaking change, though.The text was updated successfully, but these errors were encountered: