Commit 4c976293 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Prevent multiple connections.

parent 81db6e73
......@@ -1922,12 +1922,21 @@ function displayMessage(message) {
return displayError(message, "info");
}
document.getElementById('userform').onsubmit = function(e) {
let connecting = false;
document.getElementById('userform').onsubmit = async function(e) {
e.preventDefault();
let username = getInputElement('username').value.trim();
let password = getInputElement('password').value;
storeUserPass(username, password);
serverConnect();
if(connecting)
return;
connecting = true;
try {
let username = getInputElement('username').value.trim();
let password = getInputElement('password').value;
storeUserPass(username, password);
serverConnect();
} finally {
connecting = false;
}
};
document.getElementById('disconnectbutton').onclick = function(e) {
......@@ -2027,6 +2036,8 @@ window.onclick = function(event) {
};
async function serverConnect() {
if(serverConnection && serverConnection.socket)
serverConnection.close();
serverConnection = new ServerConnection();
serverConnection.onconnected = gotConnected;
serverConnection.onclose = gotClose;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment