skaarj1989/mWebSockets

Event onPing on the client

Closed this issue · 4 comments

E3ton commented

Сould you add an event listener onPing on the client?

client.onPing([](WebSocket &ws) {...

Yes, I can do that.
Out of curiosity, what do you need that for? is it urgent?

E3ton commented

It is needed for a workaround of #50
My server is regularly pinging the socket, and I want to save the last ping's timestamp so there is a way to tell if server is alive or not.

I've just pushed the feature to master branch

Here's how to use it:

client.onPing([](WebSocket &ws, const char *message, uint16_t length) {
  // ...
});
E3ton commented

Great, thanks a lot!