NetworkSession.BeginCreate Method (NetworkSessionType, Generic IEnumerable, Int32, Int32, NetworkSessionProperties, AsyncCallback, Object)

Starts hosting a new multiplayer session. The creation operation is performed asynchronously.

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

Syntax

public static IAsyncResult BeginCreate (
         NetworkSessionType sessionType,
         IEnumerable<SignedInGamer> localGamers,
         int maxGamers,
         int privateGamerSlots,
         NetworkSessionProperties sessionProperties,
         AsyncCallback callback,
         Object asyncState
)

Parameters

  • sessionType
    Type of session being created.
  • localGamers
    Collection of local gamers to participate in the network session. The first gamer in the collection becomes the host, and the others are added to the session.
  • maxGamers
    Maximum number of players allowed in this network session. For Windows- or Xbox 360-based games, this value must be between 2 and 31; 31 is the maximum number of players supported in a session. For Zune-based games, this value must be between 2 and 8; 8 is the maximum number of players supported in the session.
  • privateGamerSlots
    Number of reserved private session slots created for the session. This value must be less than maximumGamers.
  • sessionProperties
    Properties of the session being created.
  • callback
    The method to be called once the asynchronous operation has finished.
  • asyncState
    State of the asynchronous operation.

Return Value

An IAsyncResult used to track the progress of the method.

Exceptions

Exception type Condition
ArgumentOutOfRangeException One of the following conditions is true:
  • maxGamers is not in range of gamers that are supported in a network session. The XNA Framework supports multiplayer sessions between 2 and 31 players in a session for a Windows- or an Xbox 360-based game. On Zune, the XNA Framework supports a multiplayer session between 2 and 8 players in a session.
  • privateGamerSlots is less than 0 or greater than maximumGamers.
InvalidOperationException

One of the following conditions is true:

ObjectDisposedException This NetworkSession is disposed.

Remarks

Call EndCreate to get results of the call to BeginCreate.

Dd231925.note(en-US,XNAGameStudio.30).gifZune Specific Information
For Zune-based games, maxGamers must be between 2 and 8; 8 is the maximum number of players supported in the session.
Dd231925.note(en-US,XNAGameStudio.30).gifWindows Specific Information
For Windows-based games, maxGamers must be between 2 and 31; 31 is the maximum number of players supported in a session.
Dd231925.note(en-US,XNAGameStudio.30).gifXbox 360 Specific Information
For Xbox 360-based games, maxGamers must be between 2 and 31; 31 is the maximum number of players supported in a session.

See Also

Reference

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

Platforms

Xbox 360, Windows XP SP2, Windows Vista, Zune