共用方式為


NetworkSession.AllowHostMigration Property

Gets or sets whether host migration is allowed. This can be read by any machine in the session, but can only be changed by the host. The default value is false indicating that host migration is disabled.

Namespace: Microsoft.Xna.Framework.Net
Assembly: Microsoft.Xna.Framework.Net (in microsoft.xna.framework.net.dll)

Syntax

public bool AllowHostMigration { get; set; }

Property Value

true to enable host migration; false to disable host migration. The default value is false.

Exceptions

Exception type Condition
InvalidOperationException This session is not the host, and cannot change the value of AllowHostMigration.
ObjectDisposedException The session has been disposed.

Remarks

When host migration is disabled (the default state), the session will be ended if the host leaves the game or there is a network disconnect. If the host enables this setting, after they leave or disconnect a new host will automatically be selected from the machines remaining in the session, and the HostChanged event will be raised to notify you of the change. Note that game simulation state is not automatically transferred during the migration process. It is usually relatively easy for peer-to-peer games to support host migration, but rather more difficult to make this work in a client/server architecture.

See Also

Concepts

Network Topologies and Host Migration

Reference

NetworkSession Class
NetworkSession Members
Microsoft.Xna.Framework.Net Namespace

Platforms

Xbox 360, Windows 7, Windows Vista, Windows XP