Network Topologies and Host Migration
Although the XNA Framework specifies one machine as the host of a session, this does not imply anything about the network topology used to route the actual gameplay. The host is responsible for the following:
- Owning the session description on the Xbox LIVE servers
- Updating multiplayer session properities as the game state changes
- Controlling when to transition between the lobby and play states
- Removing players from the session (peers cannot directly remove other peers – only the host can do this)
Games are free to choose any network topology for their gameplay data:
- Peer-to-peer
- Client-server, where the host doubles as the server
- Client-server, using one of the other session members as the server
- Any other hybrid approach
The host and server are often the same, but they are not required to be. The host has significance to the LIVE service, while the server relates purely to gameplay. The host is chosen by the XNA Framework. The host will be the machine that creates the session. However, the host may change if there is a host migration. The game architecture determines which server is chosen. The host is an important part of XNA Framework gamer services, but the concept of a server only exists inside the game code. There are no types or properties relating to servers in the framework itself. Games need not have any server at all if they are using a pure peer-to-peer architecture.
Hosts and Peers
One of the gaming machines is designated the host for a LIVE multiplayer session. The other gaming machines are peers. The concept of host or peer is independent of the network topology chosen for the game. That is, the concept of host does not necessarily imply that the console is the network host, or even that a client-host topology is in use, even though many titles align the two concepts.
The XNA Framework automatically handles host migration. When a host leaves, the run time will automatically elect a new host. It then raises an event to inform the game of the change. Support for host migration is optional. It is disabled by default.
Note that the XNA Framework automatically migrates the host, but not the server. The game is still responsible for migrating the simulation state. This is often trivial for peer-to-peer titles, but can be more challenging for client-server architectures. If the host quits the game gracefully through a menu selection, the game code could explicitly transfer the server simulation state before actually leaving the session. However, this is very difficult to do, particularly for the more general case of forced exits such as a hardware reboot.