6.1. PiaSession Overview

This page provides an overview of PiaSession. The PiaSession module consists of various components. Understanding what each of these components does makes it easier to program with PiaSession.

Sessions and Meshes

In PiaSession, the term session refers both to the group's matchmaking session on the matchmaking server (or on a local communication network), and to the P2P mesh network for P2P communications between the players. When a session is created and players join that session, the corresponding matchmaking session or local network and P2P mesh network are automatically created and joined by the players. You can also manage the matchmaking session or local network and the P2P mesh network separately if necessary. In the PiaSession module, the P2P mesh network is simply referred to as the mesh.

Figure 6-1. Session and Mesh (When Using Internet Communication)

 

To manage the session, use session API functions that are called through the Session class. To directly control the mesh, use mesh API functions that are called through the Mesh class.

Warning:

Use of both classes at the same time is not supported. When using the Session class, use only the session API. When directly controlling the mesh, use only the mesh API.

Reference:

NEX matchmaking API functions are called inside the session API functions. For more information about the proper way to use each feature, see the chapter on matchmaking in the NEX Programming Manual.

Reference:

The PiaSession documentation assumes use of the session API unless clearly indicated otherwise. Only descriptions pertaining to the mesh API are clearly marked as being the mesh API.

 

Joint Session

PiaSession supports matchmaking among sessions to join together multiple sessions. Use the joint session feature to join together multiple sessions.

In a joint session, all stations participating in the various sessions are automatically joined into the newly created joint session. The original sessions continue to exist, and when the joint session is destroyed, the stations all return to their original sessions. As an example of how the joint session feature can be used, separate sessions could be created for separate teams, who could then compete against each other in a newly created joint session. Although three or more sessions can be joined together, a joint session cannot be joined with other sessions or other joint sessions.

 

Network Topology

This chapter describes the features of the network topologies available with PiaSession. It also includes illustrations of the connections in each topology. For more information about relay transmissions and relay connections, see  6.10. Advanced Features - Relay Communication Feature .

Full Mesh Network Topology

The full-mesh network topology is represented by the NetworkTopology_FullMesh enumerator.  Figure 6-2. Network Topology, Full-Mesh Connection shows a connection diagram for this topology.

Figure 6-2. Network Topology, Full-Mesh Connection

A full-mesh session is guaranteed to establish a direct link of communication between all pairs of stations in the session.

It has the following characteristics.

  • It tends to have lower latency.
  • Even if one station fails, the effect on communication between other stations in the session is small.
  • The success rate for joining the session drops as the number of stations in the session increases (because a station fails to join the session unless it can establish connections to all the stations already in the session).

Recommended Communication Specifications

We recommend using a full-mesh network topology if the communications of your application have specifications like the following. (This is only a recommendation. You are not prohibited from using this type of topology if you have different communication specifications.)

  • The game involves communication between a small number of participants (four or fewer stations participating in the session).
  • The game uses synchronized communication.
  • The game requires high responsiveness (such as fighting games).

Also use a full-mesh network topology if you are using PiaLocal and using PiaSession for local CTR communications. (There are no advantages to using a topology other than full mesh because local networking on CTR uses a full-mesh network anyway.)

Relay Mesh Network Topology

The relay mesh network topology corresponds to the NetworkTopology_RelayMesh enumerator.  Figure 6-3. Network Topology, Relay Mesh Connection shows a connection diagram for this topology.

Figure 6-3. Network Topology, Relay Mesh Connection

In a session using relay mesh topology, stations generally establish direct communication routes with each other, but relayed communication is used with some stations.
Relay communication is used with stations for which a direct communication route could not be established when they joined the session. (Using  Figure 6-3. Network Topology, Relay Mesh Connection Image as an example, the Client1-Client4, Client1-Client5, Client2-Client4, and Client2-Client5 pairs use relay connections because they have no direct communication route.)

If all stations in the session are able to establish direct communication routes to the other stations when joining, the connection state is equivalent to a full-mesh network, but network use is slightly higher due to system traffic from the relay connection and relay communication processes.

It has the following characteristics.

  • The success rate of joining a session does not tend to drop even if the number of stations in the session increases.
  • Stations other than the host also receive relay requests, so the communication processing load on some clients may increase (because the specifications call for lower-latency communication routes to be prioritized when selecting the route to use for a relay connection).
  • Communication may be interrupted if the station handling the relay requests has a problem. (Even if communication is temporarily interrupted, it can be restored by selecting a different station to send the relay requests.)

Recommended Communication Specifications

We recommend using the relay mesh network topology if the communications of your application have specifications like the following. (This is only a recommendation. You are not prohibited from using this type of topology if you have different communication specifications.)

  • The game involves communication between a large number of participants.
  • The game uses state synchronization.
  • The game does not require as high of responsiveness (such as FPS and racing games).