more fixes

This commit is contained in:
Jonas Weinz 2019-03-24 19:10:46 +01:00
parent 3a22acf510
commit dffdf613e6
2 changed files with 43 additions and 6 deletions

View File

@ -90,7 +90,7 @@ class OnlineMatchManager
{ {
if (this.match_button_div != null) if (this.match_button_div != null)
{ {
clearInner(this.match_button_div) clearInner(this.match_button_div);
this.matches_container.container.removeChild(this.match_button_div); this.matches_container.container.removeChild(this.match_button_div);
this.match_button_div = null; this.match_button_div = null;
} }

View File

@ -64,18 +64,40 @@ class WebsocketConnection
on_open(username, pw) on_open(username, pw)
{ {
this.connected = true; this.connected = true;
this.login(username, pw) this.login(username, pw)
} }
on_reopen(session_id) on_reopen(session_id)
{ {
this.connected = true; this.connected = true;
this.relogin(session_id); this.relogin(session_id);
} }
on_close(login_failed=false) on_close(login_failed=false)
{ {
for (var key in this.openmatches)
{
this.openmatches[key].remove_match();
}
this.openmatches = {};
// remove complete friend list:
var n = this.friend_name_divs.length;
var i;
for (i = 0; i < n; i++)
{
clearInner(this.friend_name_divs[i]);
this.search_container.container.removeChild(this.friend_name_divs[i]);
this.friend_name_divs[i] = null;
}
this.friend_name_divs = [];
this.friends = [];
var login_failed = !this.registered; var login_failed = !this.registered;
this.registered = false; this.registered = false;
this.connected = false; this.connected = false;
@ -89,6 +111,26 @@ class WebsocketConnection
on_error() on_error()
{ {
for (var key in this.openmatches)
{
this.openmatches[key].remove_match();
}
this.openmatches = {};
// remove complete friend list:
var n = this.friend_name_divs.length;
var i;
for (i = 0; i < n; i++)
{
clearInner(this.friend_name_divs[i]);
this.search_container.container.removeChild(this.friend_name_divs[i]);
this.friend_name_divs[i] = null;
}
this.friend_name_divs = [];
this.friends = [];
console.log("error in websocket connection"); console.log("error in websocket connection");
this.registered = false; this.registered = false;
this.connected = false; this.connected = false;
@ -449,11 +491,6 @@ class WebsocketConnection
close() close()
{ {
for (var key in this.openmatches)
{
this.openmatches[key].remove_match();
}
this.openmatches = {};
this.status_label.innerHTML = "logged out"; this.status_label.innerHTML = "logged out";
this.closed_by_user = true; this.closed_by_user = true;
this.socket.close(); this.socket.close();