Station identification tokens can be used to identify (differentiate) individual stations based on any kind of application data.
Session participants can get the identification token data bound to each participating station. When using this shared feature, pass the identification token that indicates the local device (the one bound to the station of the local device) in the pToken member of the Session::StartupSetting structure used when calling the Session::Startup function during the session startup. You cannot change the identification token for the local device outside of the Session::Startup function.
// Configured at session startup.
nn::pia::session::Session::StartupSetting startupSetting; // The setting for the name associated with the local station (the name shown in the game screen). nn::pia::transport::Station::PlayerName playerName; // Set a name of up to 16 characters, together with the language code. // In the sample demo, the name of the Mii is set as an example. GetLocalPlayerName(&playerName); startupSetting.pPlayerName = &playerName; // Setting for the identification token representing the the local station. nn::pia::transport::Station::IdentificationToken localToken; // LOCAL_TOKEN_DATA is the starting address of the data string for the identification token of size IDENTIFICATION_TOKEN_MAX_DATA_SIZE [byte]. ::std::memcpy(localToken.data, LOCAL_TOKEN_DATA, nn::pia::transport::Station::IDENTIFICATION_TOKEN_MAX_DATA_SIZE); startupSetting.pToken = &localToken; result = nn::pia::session::Session::GetInstance()->Startup(startupSetting); if (result.IsFailure()) { // Error processing. } /* Go to process to build or join a session. */ |
You can get the configured identification token from each session participant after the session joining process has completed.
// Can be run while participating in a session.
nn::pia::StationId targetId; // StationId represents the target station the token is being obtained for. nn::pia::transport::Station* pTargetStation = nn::pia::transport::StationManager::GetInstance()->GetStation(targetId); if (pTargetStation != NULL) { nn::pia::transport::Station::IdentificationToken tokenBuf; // Get the identification token for a station. result = pTargetStation->GetIdentificationToken(&tokenBuf); if (result.IsFailure()) { // Error processing. } } /* The identification token for pTargetStation is stored in tokenBuf if it is obtained successfully. */ |