Share via


NetworkSession.BeginCreate Method (NetworkSessionType, Int32, 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.Net (in microsoft.xna.framework.net.dll)

Syntax

public static IAsyncResult BeginCreate (
         NetworkSessionType sessionType,
         int maxLocalGamers,
         int maxGamers,
         int privateGamerSlots,
         NetworkSessionProperties sessionProperties,
         AsyncCallback callback,
         Object asyncState
)

Parameters

  • sessionType
    Type: NetworkSessionType
    Type of session being created.
  • maxLocalGamers
    Type: Int32
    Maximum number of local players on the same gaming machine in this network session.
  • maxGamers
    Type: Int32
    Maximum number of players allowed in this network session. For games based on Windows or Xbox 360, this value must be between 2 and 31; 31 is the maximum number of players supported in a session.
  • privateGamerSlots
    Type: Int32
    Number of reserved private session slots created for the session. This value must be less than maximumGamers.
  • sessionProperties
    Type: NetworkSessionProperties
    Properties of the session being created.
  • callback
    Type: AsyncCallback
    The method to be called once the asynchronous operation is finished.
  • asyncState
    Type: Object
    State of the asynchronous operation.

Return Value

An IAsyncResult used to track the progress of the method. Call EndCreate to access these results.

Exceptions

Exception type Condition
ArgumentOutOfRangeException One of the following conditions is true:
  • maxGamers is not in the range of gamers that are supported in a network session. The XNA Framework supports multiplayer sessions between two and 31 players in a session for a Windows or an Xbox 360 game.
  • 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.

Bb975185.note(en-us,XNAGameStudio.41).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.
Bb975185.note(en-us,XNAGameStudio.41).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

Overview

Working with Asynchronous Methods in XNA Game Studio

Reference

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

Platforms

Xbox 360, Windows 7, Windows Vista, Windows XP