kiwiirc / irc-framework

🛠️ A better IRC framework for node.js. For bots and full clients.
MIT License
181 stars 63 forks source link

Rework client ping and timeout functions #297

Closed ItsOnlyBinary closed 2 years ago

ItsOnlyBinary commented 3 years ago

This should help with connectivity on mobile browsers that pause setTimeout() events when no longer focused.

It does so by triggering resetPingTimeoutTimer() here:

https://github.com/kiwiirc/irc-framework/blob/a515b1bd3c34aab8f30c6e97c4abb3f0d36dd8bb/src/client.js#L199-L200

ItsOnlyBinary commented 3 years ago

seems for this pr i should also address #232

ItsOnlyBinary commented 3 years ago

I've also now split the periodic ping and timeout code so they can be started at different points in the connection cycle.

One of the changes to periodic ping is to set the next ping timer using the pong event to break the loop of a timeout setting another timeout. For more info on why see here: https://developer.chrome.com/blog/timer-throttling-in-chrome-88/