static private BeginCreate ( string serverHost, SessionType sessionType, int maxLocalGamers, int maxGamers, int privateReservedSlots, SessionProperties sessionProperties, AsyncCallback callback, object asyncState ) : IAsyncResult | ||
serverHost | string | |
sessionType | SessionType | |
maxLocalGamers | int | |
maxGamers | int | |
privateReservedSlots | int | |
sessionProperties | SessionProperties | |
callback | AsyncCallback | |
asyncState | object | |
return | IAsyncResult |
internal static IAsyncResult BeginCreate(string serverHost, SessionType sessionType, int maxLocalGamers, int maxGamers, int privateReservedSlots, SessionProperties sessionProperties, AsyncCallback callback, object asyncState)
{
if ((maxLocalGamers < 1) || (maxLocalGamers > 4))
{
throw new ArgumentOutOfRangeException("maxLocalGamers");
}
if (maxGamers < 1 || maxGamers > 31)
{
throw new ArgumentOutOfRangeException("maxGamers");
}
if ((privateReservedSlots < 0) || (privateReservedSlots >= maxGamers))
{
throw new ArgumentOutOfRangeException("privateReservedSlots");
}
var asyncCreate = new AsynchronousCreate(Create);
return asyncCreate.BeginInvoke(serverHost, sessionType, maxGamers, privateReservedSlots, sessionProperties, true, callback, asyncState);
}
/// <summary> /// Creates a wide area network session /// </summary> /// <param name="maxPlayers">The total maximum players for this session</param> /// <param name="sessionProperties">The SessionProperties that will be used to find this session on the network. Can be null</param> /// <remarks>it doesn't yet support multiple local players</remarks> public override void CreateWanSession(int maxPlayers, SessionProperties sessionProperties) { IPAddress ipAddress; var host = NetUtility.GetMyAddress(out ipAddress); _networkSessionLocker = CreatingSession; LidgrenSession.BeginCreate(host.ToString(), SessionType.WideAreaNetwork, 1, maxPlayers, 0, sessionProperties, OnLidgrenSessionCreated, _networkSessionLocker); }