1.7. Station IDs

Station IDs

Each module uses the station IDs (the StationId structure) as a station identifier. Station IDs consist of a uniquely assigned unique ID within the session that is assigned upon joining the session.

The unique ID has the same value as the principal ID assigned on the friend presence server when the Internet is used for communication; it has the same value as the station index for local communications.

Code 1-7. Station IDs
struct StationId
{
    u32 uniqueId; //!< The station's unique value.
    u32 reserved; //!< A reserved region.
}

Station Indexes

A feature is available for converting the station IDs for stations participating in a session to values in a range from 0 to the value (the maximum number of session joinable participants - 1). This value is called the station index (StationIndex). Functionality also exists to convert from a station index to a station ID.

Conversion uses the nn::pia::transport::Transport::ConvertToStationIndex() and ConvertToStationId() functions. These conversion functions can be used during the time between when the EVENT_JOIN event and the EVENT_LEAVE event are reported for the target StationId. The conversion can also be done in the callback functions that report these events.

Station indexes are a useful way to manage the game objects for each station as an array.

Cautions on the Use of Joint Sessions

With Internet communications, you can use the joint session feature, which works to join together multiple sessions. When you use this feature, the station IDs before and after joining do not change their values, but the station indexes associated with the station IDs do change. For this reason, if you are using station indexes for the array of game objects for each station, you must update these station indexes when sessions are joined together.

For more information about joint sessions, see 6.12. Advanced Features - Joint Session Feature.