ft_transcendence/transcendence/abstract/AbstractRoomMember.py

16 lines
419 B
Python
Raw Normal View History

2023-12-23 12:11:30 -05:00
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)