You can determine whether to allow a station to join a session at the time of joining.
Only the session host has the authority to determine whether a request to join a session is either approved or denied. When performing a determination, prepare the determination callback function and register it to the session. When a join request arrives while the determination callback function is not registered, it is usually approved.
// Executable if an instance of the Session class exists.
// Register a determination callback function to the Session class. nn::pia::session::Session::GetInstance()->RegisterJoiningApprovalCallback(sampleJoinApprovalCallback); // This callback function is called when the station acting as the session host receives a join request // while the callback is registered until it is unregistered. // Unregisters the Session class determination callback function. nn::pia::session::Session::GetInstance()->UnregisterJoiningApprovalCallback(); |
The code for the determination callback is implemented in the application.
Do not include any processes that would block for a long time within the callback function. This can negatively affect system processes.
The only times outside of the determination callback that a join request can be denied is either when a session is full or during host migration.
// Example of a join-in request approval determination callback function
bool sampleJoinApprovalCallback(const nn::pia::transport::Station::IdentificationToken* pRequesterToken) { bool judgment; // Write the code for determining approval of a join request. The pRequesterToken parameter // is the pointer to the identification token for the station requesting approval to join. // Do not include code that blocks for a long period of time because that might impact the system. if (judgment) { // Approve if 'true' is returned. return true; } else { // Deny if 'false' is returned. return false; } } |