matchmaking: add: clear message if normal closure

This commit is contained in:
starnakin 2023-12-23 18:47:16 +01:00
parent 88aca3a54b
commit 397344ee45
5 changed files with 9 additions and 7 deletions

View File

@ -39,7 +39,7 @@ class MatchMaking
onclose(event)
{
this.stop();
this.disconnect_func()
this.disconnect_func(event);
}
async stop()

View File

@ -25,8 +25,10 @@ export default class extends AbstractAuthentifiedView {
}
}
ondisconnect()
ondisconnect(event)
{
if (event.code === 1000)
clear("innerText", ["detail"])
document.getElementById("button").value = "Find a game"
}

View File

@ -38,4 +38,4 @@ class MatchMaking(WebsocketConsumer):
waiting_room: WaitingRoom = normal.get(self.mode)
waiter: Waiter = waiting_room.get_member_by_socket(self)
if (waiter is not None):
waiting_room.remove(waiter)
waiting_room.remove(waiter, 1016)

View File

@ -35,9 +35,9 @@ class AbstractRoom:
self._member_list.append(waiter)
member.accept()
def remove(self, member: AbstractRoomMember):
def remove(self, member: AbstractRoomMember, code: int = 1000):
self._member_list.remove(member)
member.disconnect()
member.disconnect(code)
def empty(self):
for _ in self._member_list:

View File

@ -16,5 +16,5 @@ class AbstractRoomMember:
def accept(self):
self.socket.accept()
def disconnect(self):
self.socket.disconnect(200)
def disconnect(self, code: int = 1000):
self.socket.disconnect(code)