async def test_browse(): def handler(): return [make_session_info(100)] s = settings.Settings(50900, 0) async with lan.serve(s, handler, bytes(16)): crit = lan.LanSessionSearchCriteria() sessions = await lan.browse(s, crit, bytes(16), max=1) assert len(sessions) == 1 assert sessions[0].session_id == 100
async def main(): search_criteria = lan.LanSessionSearchCriteria() s = settings.default(SMM2.PIA_VERSION) sessions = await lan.browse(s, search_criteria, SMM2.PIA_KEY) if sessions: print("LAN sessions found:") for session in sessions: print_session_info(session) else: print("No LAN session found")
async def test_browse_max(): def handler(): return [make_session_info(100), make_session_info(101)] s = settings.Settings(50900, 0) async with lan.serve(s, handler, bytes(16)): crit = lan.LanSessionSearchCriteria() sessions = await lan.browse(s, crit, bytes(16), max=2) assert len(sessions) == 2 ids = set(session.session_id for session in sessions) assert ids == {100, 101}
print("\tAttributes: %s" % info.attributes) print("\tCurrent number of players: %i" % info.num_participants) print("\tMinimum number of players: %i" % info.min_participants) print("\tMaximum number of players: %i" % info.max_participants) print("\tSystem communication version: %i" % info.system_version) print("\tApplication communication version: %i" % info.application_version) print("\tSession type: %i" % info.session_type) print("\tApplication data: <%i bytes>" % len(info.application_data)) print("\tIs opened: %s" % info.is_opened) print("\tPlayers:") for player in info.players: if player.id != 0: print("\t\t<%i, %s, %i>" % (player.role, player.username, player.id)) print("\tHost: %s" % info.host_location.get_station_url()) print("\t-----") browser = lan.LANBrowser("switch.cfg", SMM2.PIA_KEY) browser.configure(SMM2.PIA_VERSION) search_criteria = lan.LanSessionSearchCriteria() sessions = browser.browse(search_criteria) if sessions: print("LAN sessions found:") for session in sessions: print_session_info(session) else: print("No LAN session found")