Answer the question
In order to leave comments, you need to log in
How to remove a client from a room when a socket is disconnected?
Good day!
There is a standard function to disconnect a client from a room:
def __client_leave_room(self, data):
"""
Метод отключения клиента от комнаты.
:param data: Данные пользователя. Приходят с клиента.
:return:
"""
username = data["username"]
name_room = data["room"]
if name_room not in self.__list_rooms:
# Ошибка, такой комнаты нет.
pass
leave_room(name_room)
print(f"{username}'s disconnected from {name_room}")
socket.on("disconnect", function() {
socket.emit("leave", {username: username, room: room});
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question