Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,11 @@ module.exports = class IrcClient extends EventEmitter {

startPeriodicPing() {
const client = this;
let ping_timer = null;

if (client.options.ping_interval <= 0) {
return;
} else if (client.periodic_ping_timer && client.connection.hasTimeout(client.periodic_ping_timer)) {
return; // do not create duplicate timer if already actively pinging the server
}

// Constantly ping the server for lag and time syncing functions
Expand All @@ -351,8 +352,8 @@ module.exports = class IrcClient extends EventEmitter {
}

function resetPingTimer() {
client.connection.clearTimeout(ping_timer);
ping_timer = client.connection.setTimeout(pingServer, client.options.ping_interval * 1000);
client.connection.clearTimeout(client.periodic_ping_timer);
client.periodic_ping_timer = client.connection.setTimeout(pingServer, client.options.ping_interval * 1000);
}

// Browsers have started throttling looped timeout callbacks
Expand Down Expand Up @@ -666,7 +667,11 @@ module.exports = class IrcClient extends EventEmitter {

const commandName = 'ACTION';
const blockLength = this.options.message_max_length - (commandName.length + 3);
const blocks = [...lineBreak(message, { bytes: blockLength, allowBreakingWords: true, allowBreakingGraphemes: true })];
const blocks = [...lineBreak(message, {
bytes: blockLength,
allowBreakingWords: true,
allowBreakingGraphemes: true
})];

blocks.forEach(function(block) {
that.ctcpRequest(target, commandName, block);
Expand Down
4 changes: 4 additions & 0 deletions src/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ module.exports = class Connection extends EventEmitter {
return tmr;
}

hasTimeout(tmr) {
return (this._timers.includes(tmr));
}

clearTimeout(tmr) {
clearTimeout(tmr);
_.pull(this._timers, tmr);
Expand Down