def relay_worlds_generic(world_id=None): # Android client also requests a JSON version if request.headers['Accept'] == 'application/json': world = { 'currentDateTime': int(time.time()), 'currentWorldTime': world_time(), 'friendsInWorld': [], 'mapId': 1, 'name': 'Public Watopia', 'playerCount': 0, 'worldId': 1 } if world_id: world['mapId'] = world_id return jsonify(world) else: return jsonify([world]) else: # protobuf request worlds = world_pb2.Worlds() world = worlds.worlds.add() world.id = 1 world.name = 'Public Watopia' world.f3 = 1 # Windows client crashes if playerCount is 0 world.f5 = 1 # playerCount world.world_time = world_time() world.real_time = int(time.time()) if world_id: world.id = world_id return world.SerializeToString() else: return worlds.SerializeToString()
def relay_worlds(): worlds = world_pb2.Worlds() world = worlds.worlds.add() world.id = 1 world.name = 'Public Watopia' world.f3 = 1 world.f5 = 1 world.world_time = int(time.time()) * 1000 world.real_time = int(time.time()) return worlds.SerializeToString(), 200