websocket server - user event and user event handler

50 views
Skip to first unread message

Wojciech Jędruch

unread,
Jan 16, 2022, 3:23:37 PM1/16/22
to WebSocket++
Hello All,

im quite now to websocket c++ software so im sorry if im missing something once describing issue.

Here is what i want to achive:

i took example telemetry_serever.cpp and my idea is to modify it in a way that when my sensor gets new data i pubilish it to all clients. Sensor data i read in separate thread.

what i can do is that i can pass a m_endpoint (server object) pointer into sensor object and if new data from sensor arrives i can use m_endpoint to publish all data (this will happen in sensor object). But i think (at least i feel) that is not correct way to do so. Also i can use on_timer in server object to periodically check if some changes in sensor data happend - however its rather polling which is more like workaround.

So i was wondering if  there can be kind of a user event - triggered by sensor and a user callback executed in server (like: on_message, on_interrupt, on_http) so whenever i got new data i can send it into all clients?

thank you for support
Wojciech

Reply all
Reply to author
Forward
0 new messages