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.
This commit is contained in:
Дамјан Георгиевски 2022-02-04 15:48:29 +01:00 committed by Simon Ser
parent f465e24adf
commit 1142145c6d
2 changed files with 6 additions and 4 deletions

View File

@ -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) {

View File

@ -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;