CTR Pia  4.11.3
Game Communication Engine
session/Mesh Sample Demo

Introduction

This demo illustrates the usage of the nn::pia::session::Mesh class. The demo uses the following features.

  • Station ID tokens
  • Approval and denial of session join requests
  • Canceling the session-joining process
  • Relay communication
  • Host migration
  • Round robin communication

Scope of the demo

This sample primarily demonstrates the following.

Process Overview and Controls in Each State

Selecting the Communication Route and Station ID Token Type

In this state, the communication method, station identification tokens used for communication, and network topology are selected.

You automatically transition to this state on start.

Input Operation
+Control Pad
  • Select the station ID token type. Two types of token patterns are available for use in this demo.
    Select the network topology. This also updates the communication mode option, to prevent the station from connecting to stations with different network topology settings.
  • Change communication mode option settings. Use this setting when creating or searching for a matchmaking session on the local network or over the Internet.
A Button Start communication via local communication (UDS). Once selected, you transition to the matchmaking (local) state.
B Button Starts communication via the Internet. Once selected, you transition to the network connection (Internet) state.

Matchmaking (Local) State

In the matchmaking (local) state, the local device searches for nearby networks and selects a network to connect to as a client.
When using local communication, typically only one session is on the network, so in this demo the local station automatically joins the session created by the host once successfully connected to the network.

You can also create a new network and session. (In this case, the local device acts as the host.))

Input Operation
Up/down on the +Control Pad Select the network to connect to.
A Button Connect to the selected network and join the session. The demo transitions to the session-joining state.
B Button The demo transitions to the Selecting the Communication Route and Station ID Token Type screen.
X Button Establish a new network and session. After you successfully create a session, you transition to the connected state.

Network Connection (Internet) State

Establishes an Internet connection.
When the Internet connection is complete and the inet module is initialized, you automatically transition to the matchmaking (Internet) state.

If the connection or inet module initialization fails, you transition to the error display state.

Matchmaking (Internet) State

This state uses the NEX matchmaking feature to communicate with the game server and establish a session.

For the Internet matchmaking in this demo, the session search is not automatic as it is for local communication.
(Note: Frequent session searches place a heavy load on the server.)

Input Operation
Up/down on the +Control Pad Select the session you want to join.
A Button Join the selected session. (You cannot join a session with a different ID token type.)
The demo transitions to the session-joining state.
B Button Logs out from the game server and disconnects from the Internet. The demo then transitions to the Selecting the Communication Route and Station ID Token Type screen.
X Button Create a new session. After you join a session, the demo transitions to the Connected state.
Y Button Query the game server and update the session list.

Session-Joining State

In this state, you are waiting for the asynchronous process for joining a session to finish. If the asynchronous process succeeds, you transition to the communication state.

Input Operation
B Button Cancels the session-joining process. When the cancellation is complete, you transition to the matchmaking state.

Communication State

Communication occurs among the nodes in the session.
In this state, each of the nodes communicates in the following way.

  • Sends a packet broadcast (to all members) at a rate of 60 times per second. (The nodes transmit the position of the rectangle displayed on the upper screen to each other.)

A character (rectangle) is assigned to each connected node and displayed to indicate that communication is taking place.
A StationIndex and player name are displayed to the right of each character.

If you disconnect from the network, the demo returns to Selecting the Communication Route and Station ID Token Type.
If you were unintentionally disconnected from the network, the demo transitions to the error display state.

Network information for the local device and the session host appears at the bottom of the lower screen as a debugging feature.

Input Operation
+Control Pad Moves the position of the rectangle displayed on the upper screen.
When there is no input from the +Control Pad, the rectangle moves to the right to indicate that communication is taking place.
B Button Exits the session and transitions to the matchmaking state.
If acting as the host, the station either leaves the session by performing host migration or destroys the session, depending on the host migration settings.
R Button + B Button After leaving a session, the demo transitions to Selecting the Communication Route and Station ID Token Type. This happens after logging out from the game server and disconnecting from the Internet when connected to the Internet, and after disconnecting from the local network when connected to a local network.
A Button Enable or disable the use of round robin communication.
Text displayed to the right of the character (rectangle) is yellow in the case of stations for which round robin communication is enabled. This allows you to check the enabled or disabled status of this feature according to the color of this text.
R Button + down on the +Control Pad Enables or disables the use of nearby network search (during local communication).
Enabled for the host only.
R Button + wp on the +Control Pad Updates the beacon application data (during local communication).
Only the host can update. Clients can get the updates.
R Button (+ X Button) + right on the +Control Pad Allows or denies new joins (during local communication). Only rejoins are permitted when the X Button is pressed.
Enabled for the host only.

Error Display State

You transition to the error display state when you cannot communicate because you are in wireless-disabled mode, or when communication cannot be maintained.
Error types are shown in the following list.

  • Initialization failed because you are in wireless-disabled mode.
  • Initialization failed for other reasons.
  • A communication error has occurred.
  • Matchmaking failed.
  • The session was lost.
  • The network connection was lost.
Input Operation
A Button Exits this state and, after reinitialization, you transition to the Selecting the Communication Route and Station ID Token Type.