api.login(USERNAME, PASSWORD)

pid = api.get_pid(USERNAME)
mii = api.get_mii(pid)

nex_token = api.get_nex_token(friends.FriendsTitle.GAME_SERVER_ID)
backend = backend.BackEndClient(friends.FriendsTitle.ACCESS_KEY,
                                friends.FriendsTitle.NEX_VERSION,
                                backend.Settings("friends.cfg"))
backend.connect(nex_token.host, nex_token.port)
backend.login(nex_token.username, nex_token.password, None,
              authentication.NintendoLoginData(nex_token.token))

#Even though you're sending your username and pid to the server, you can't
#requests friend information of other people. You'll always get your own data
client = friends.FriendsClient(backend)
principal_preference, comment, friends, requests_sent, requests_received, \
  blacklist, unk1, notifications, unk2 = client.get_all_information(
    friends.NNAInfo(
        friends.PrincipalBasicInfo(
   pid, USERNAME, #Pid and nnid
   #If you change mii name or data here it will also be changed on Nintendo's servers
   friends.MiiV2(mii.name, 0, 0, mii.data, common.DateTime(0)),
   2
        ),
        0x5E, 0x0B
    ),
    #NintendoPresenceV2 tells the server about your online status, which
    #game you're currently playing, etc. This will be shown to your friends
    #in their friend list (unless you disabled this feature).
    friends.NintendoPresenceV2(
Esempio n. 2
0
    client.connect(nex_token.host, nex_token.port)
    client.login(nex_token.username, nex_token.password, auth_info, login_data)
    return client


nnas = NNASClient()
nnas.set_device(DEVICE_ID, SERIAL_NUMBER, SYSTEM_VERSION, REGION, COUNTRY)
nnas.login(USERNAME, PASSWORD)

#Connect to both the Mario Kart 8 server and the Wii U friends server
friends_backend = backend_login(Friends, False, True, "friends.cfg")
game_backend = backend_login(MK8, True, False)

pid = game_backend.get_pid()

friends_client = friends.FriendsClient(friends_backend.secure_client)
matchmaker = matchmaking.MatchmakeExtensionClient(game_backend.secure_client)

#Create a matchmake session
matchmake_session = matchmaking.MatchmakeSession()
matchmake_session.player_min = 2
matchmake_session.player_max = 12
matchmake_session.participation_policy = 98
matchmake_session.game_mode = 3
matchmake_session.attribs[4] = 0x403  #DLCs enabled
matchmake_session.matchmake_system = matchmaking.MatchmakeSystem.FRIENDS

session_id = matchmaker.create_matchmake_session(matchmake_session, "", 1).gid

#Tell friends we're playing MK8 and have created a room
application_data = b"\0\0\x20\x03\0\0\0\0\0\0\0\0\x18" + struct.pack(
	return client


api = AccountAPI()
api.set_device(DEVICE_ID, SERIAL_NUMBER, SYSTEM_VERSION, REGION, COUNTRY)
api.login(USERNAME, PASSWORD)

#Connect to both the Mario Kart 8 server and the Wii U friends server
friends_backend = backend_login(
	friends.FriendsTitle, False, True, backend.Settings("friends.cfg")
)
game_backend = backend_login(MK8, True, False)

pid = game_backend.auth_client.pid

friends_client = friends.FriendsClient(friends_backend)
matchmaker = matchmaking.MatchmakeExtensionClient(game_backend)

#Create a matchmake session
matchmake_session = matchmaking.MatchmakeSession(
	#Create a gathering with between 2 and 12 players
	#and the participation policy set to 98
	0, 0, 0, 2, 12, 98, 0, 0, 0, "",
	3, [0, 0, 0, 0, 0x403, 0], #game mode = 3, flags = 0x403 (DLCs enabled)
	True, #Open participation
	matchmaking.MatchmakeSystem.FRIENDS, #Only friends will join
	b"", 0, b"", 100, 0
)
session_id, session_key = matchmaker.create_matchmake_session(
	matchmake_session, "", 1
)