我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用flask_socketio.join_room()。
def on_connect(self, request_id): user = self.app.user_tracker.users[self.app.user_tracker.requests[request_id]] if user.socket_connected: return user.socket_connect() flask_socketio.join_room(request_id)
def sub_instrument(message): print('{0}:join_room'.format(message)) join_room(message)
def _enable_websocket_rooms(self): socket = self.server socket.on_event('join', join_room) socket.on_event('leave', leave_room)
def on_socketio_connect(): # ????????????? webhook user_id = RequestUtil.get_login_user().get('id', '') # ???????? if not user_id: return False webhooks = AuthUtil.has_auth_webhooks(user_id) for webhook in webhooks: flask_socketio.join_room(webhook.id)
def on_join(data): room_id = data["room_id"] if room_id not in active_rooms: raise Exception("Room does not exist") room = active_rooms[room_id] new_player = room.add_new_player(UUID(request.sid)) active_players[UUID(request.sid)] = new_player join_room(room_id) player_list = list(map(lambda x: str(x), room.players.keys())) socketio.emit("game_update", build_game_update_payload(room), room=str(room_id))