ft_transcendence/transcendence/abstract/AbstractRoomMember.py
2023-12-23 18:11:30 +01:00

16 lines
419 B
Python

class AbstractRoomMember:
def __init__(self, user_id: int, socket: WebsocketConsumer):
self.user_id: int = user_id
self.socket: WebsocketConsumer = socket
def send(self, detail: str, data: dict = {}):
raw_data: dict = {"detail": detail}
raw_data.update(data)
self.socket.send(text_data=json.dumps(raw_data))
def accept(self):
self.socket.accept()
def disconnect(self):
self.socket.disconnect(200)