共用方式為


NetworkSession Members

The following tables list the members exposed by the NetworkSession type.

Public Fields

Name Description
Public Field MaxSupportedGamers Maximum number of gamers supported in a session.

Public Properties

Name Description
Public Property AllGamers Gets the collection of gamers currently in the session.
Public Property AllowHostMigration 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.
Public Property AllowJoinInProgress Gets or sets whether join-in-progress is allowed. If the host enables this setting, new machines will be able to join at any time. The default value is false, indicating that join-in-progress is disabled. AllowJoinInProgress can be read by any machine in the session, but can only be changed by the host.
Public Property BytesPerSecondReceived Gets a performance counter recording the amount of data being received from the network.
Public Property BytesPerSecondSent Gets a performance counter recording the amount of data being sent over the network.
Public Property Host Gets the current host of the multiplayer session.
Public Property IsDisposed Gets a value that indicates whether the object is disposed.
Public Property IsEveryoneReady Determines whether all gamers are ready to enter the session.
Public Property IsHost Determines whether this machine is the session host.
Public Property LocalGamers Get the collection of local gamers for a multiplayer session.
Public Property MaxGamers Gets or sets the maximum number of players able to join this multiplayer session.
Public Property PrivateGamerSlots Gets or sets the number of private slots reserved for gamers who join using an invitation.
Public Property RemoteGamers Gets the collection of remote gamers for a multiplayer session.
Public Property SessionProperties Gets any custom properties that have been attached to the session.
Public Property SessionState Gets the current state of a multiplayer session.
Public Property SessionType Gets the current multiplayer session type.
Public Property SimulatedLatency Gets or sets the amount of simulated network latency.
Public Property SimulatedPacketLoss Gets or sets the amount of simulated packet loss.

Public Methods

Name Description
Public Method AddLocalGamer Adds the specified local gamer profile to the network session.
Public Method Static BeginCreate Overloaded. Starts hosting a new multiplayer session.
Public Method Static BeginFind Overloaded. Starts a matchmaking query to search for available multiplayer sessions.
Public Method Static BeginJoin Starts a join operation for the specified multiplayer session.
Public Method Static BeginJoinInvited Overloaded. Starts joining an existing network session in response to an InviteAccepted notification event. Call EndJoinInvited to access the asynchronous method results.
Public Method Static Create Overloaded. Hosts a new multiplayer session.
Public Method Dispose Ends the current multiplayer session.
Public Method Static EndCreate Gets the result from a BeginCreate asynchronous call.
Public Method Static EndFind Gets the result from a BeginFind asynchronous call.
Public Method EndGame Changes the session state from NetworkSessionState.Playing to NetworkSessionState.Lobby.
Public Method Static EndJoin Gets the result from a BeginJoin asynchronous call.
Public Method Static EndJoinInvited Gets the result from a BeginJoinInvited asynchronous call.
Public Method Equals (Inherited from Object.)
Public Method Static Find Overloaded. Issues a matchmaking query, searching for available multiplayer sessions.
Public Method FindGamerById Looks up the network gamer with the specified ID.
Public Method GetHashCode (Inherited from Object.)
Public Method GetType (Inherited from Object.)
Public Method Static Join Joins an existing multiplayer session.
Public Method Static JoinInvited Overloaded. Joins an existing network session in response to an InviteAccepted notification event.
Public Method ReferenceEquals (Inherited from Object.)
Public Method ResetReady Resets the IsReady property of all session gamers.
Public Method StartGame Changes the session state from NetworkSessionState.Lobby to NetworkSessionState.Playing.
Public Method ToString (Inherited from Object.)
Public Method Update Updates the state of the multiplayer session.

Protected Methods

Name Description
Protected Method Finalize Allows this object to attempt to free resources and perform other cleanup operations before garbage collection reclaims the object.
Protected Method MemberwiseClone (Inherited from Object.)

Public Events

Name Description
Public Event GameEnded Occurs when the game moves from gameplay to the lobby.
Public Event GamerJoined Occurs when a new player joins a multiplayer session.
Public Event GamerLeft Occurs when a player leaves the multiplayer session.
Public Event GameStarted Occurs when the game moves from the lobby into actual gameplay.
Public Event HostChanged Occurs when the session host has changed.
Public Event Static InviteAccepted Event that occurs when a user has accepted an invite to join a network session.
Public Event SessionEnded Occurs when the multiplayer session ends.

See Also

Reference

NetworkSession Class
Microsoft.Xna.Framework.Net Namespace