websocketpp icon indicating copy to clipboard operation
websocketpp copied to clipboard

Heartbeat

Open chlebicz opened this issue 7 years ago • 3 comments

Hello. I need to send a "heartbeat" message every specified time after receiving a initial message. I tried stuff like std::thread but I can't keep one thread active because I have to handle other messages. Is there any way to do this?

chlebicz avatar Apr 15 '19 08:04 chlebicz

@zaphoyd any solutions?

chlebicz avatar Apr 15 '19 23:04 chlebicz

Ok, I found that the server sends event like heartbeat ack after receiving the heartbeat so I decided to send heartbeat once the client goes online and after receiving that heartbeat ack but:

Sleep(interval);
c->send(hdl, heartbeat, websocketpp::frame::opcode::text);

only connects the bot but doesn't keep receiving other events because the thread is still active.

chlebicz avatar Apr 16 '19 10:04 chlebicz

thank you for help ( :) )

chlebicz avatar May 16 '19 13:05 chlebicz