async def call_message(self, event): user_id = event['sender_id'] nickname = get_user_nickname(user_id) msg = f'{nickname}이 올린 금액을 승낙했습니다.' msg_obj = ClientMessage('CALL', msg) await self.send_message(msg_obj.to_json(), msg_obj.type)
async def die_message(self, event): user_id = event['sender_id'] nickname = get_user_nickname(user_id) msg = f'{nickname}이 포기했습니다.' msg_obj = ClientMessage('DIE', msg) await self.send_message(msg_obj.to_json(), msg_obj.type)
async def check_message(self, event): user_id = event['sender_id'] nickname = get_user_nickname(user_id) msg = f'{nickname}님이 check했습니다.' msg_obj = ClientMessage('CHECK', msg) await self.send_message(msg_obj.to_json(), msg_obj.type)
async def turn_message(self, event): next_user = event['sender_id'] nickname = get_user_nickname(next_user) msg = f'{nickname}님 차례입니다.' msg_obj = ClientMessage('ORDER', msg) msg_obj.this_turn = next_user await self.send_message(msg_obj.to_json(), msg_obj.type)
async def ready_message(self, event): user_id = event['sender_id'] nickname = get_user_nickname(user_id) msg = f'{nickname}님이 레디를 눌렀습니다.' msg_obj = ClientMessage('READY', msg) await self.send_message(msg_obj.to_json(), msg_obj.type)
async def bet_message(self, event): user_id = event['sender_id'] bet = event['bet'] nickname = get_user_nickname(user_id) msg = f'{nickname}이 {bet}만큼 베팅 금액을 올렸습니다. .' msg_obj = ClientMessage('BET', msg) await self.send_message(msg_obj.to_json(), msg_obj.type)
async def enter_message(self, event): nickname = get_user_nickname(event['sender_id']) msg = f'{nickname}님이 입장하셨습니다' msg_obj = ClientMessage('ENTER', msg) # send message to websocket await self.send_message(msg_obj.to_json(), msg_obj.type)
async def choice_message(self, event): next_user = event['next_user'] opponent_card = event['opponent_card'] this_round = event['round'] nickname = get_user_nickname(next_user) msg = f'{nickname}님 선택해주세요' msg_obj = ClientMessage('GAME', msg) msg_obj.this_round = this_round msg_obj.my_point = get_user_point(next_user) msg_obj.set_card_info(me=next_user, opponent_card=opponent_card) await self.send_message(msg_obj.to_json(), msg_obj.type)
async def exit_message(self, event): user_id = event['sender_id'] room_id = event['room_id'] nickname = get_user_nickname(user_id) # leave room group await self.channel_layer.group_discard(user_id, self.channel_name) await self.channel_layer.group_discard(room_id, self.channel_name) msg = f'{nickname}님이 퇴장하셨습니다' msg_obj = ClientMessage('EXIT', msg) await self.send_message(msg_obj.to_json(), msg_obj.type) await self.close()