From 1142145c6d52629283ac1fdf84cc8a36516e6684 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BC=D1=98=D0=B0=D0=BD=20=D0=93=D0=B5=D0=BE?= =?UTF-8?q?=D1=80=D0=B3=D0=B8=D0=B5=D0=B2=D1=81=D0=BA=D0=B8?= Date: Fri, 4 Feb 2022 15:48:29 +0100 Subject: [PATCH] fix ping after reconnect client.setPingInterval was only called once in app.connect(), but client.disconnect() disables it, and the ping timer is never again set, even though the client can reconnect. the change passes the ping time as a parameter to the client, and the client calls setPingInterval() after a successful WS open event. --- components/app.js | 8 ++++---- lib/client.js | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/components/app.js b/components/app.js index 6354bdd..9b650ec 100644 --- a/components/app.js +++ b/components/app.js @@ -159,6 +159,7 @@ export default class App extends Component { saslExternal: false, autoconnect: false, autojoin: [], + ping: 0, }, connectForm: true, loading: true, @@ -253,6 +254,9 @@ export default class App extends Component { if (config.server.auth === "external") { connectParams.saslExternal = true; } + if (typeof config.server.ping === "number") { + connectParams.ping = config.server.ping; + } } let autoconnect = store.autoconnect.load(); @@ -652,10 +656,6 @@ export default class App extends Component { if (params.autojoin.length > 0) { this.switchToChannel = params.autojoin[0]; } - - if (this.config.server && typeof this.config.server.ping !== "undefined") { - client.setPingInterval(this.config.server.ping); - } } disconnect(serverID) { diff --git a/lib/client.js b/lib/client.js index 1bb62e4..bced0be 100644 --- a/lib/client.js +++ b/lib/client.js @@ -122,6 +122,7 @@ export default class Client extends EventTarget { saslPlain: null, saslExternal: false, bouncerNetwork: null, + ping: 0, }; debug = false; batches = new Map(); @@ -244,6 +245,7 @@ export default class Client extends EventTarget { this.setStatus(Client.Status.REGISTERING); this.reconnectBackoff.reset(); + this.setPingInterval(this.params.ping); this.nick = this.params.nick;