本文整理汇总了C#中Microsoft.Xna.Framework.Net.NetworkSessionProperties类的典型用法代码示例。如果您正苦于以下问题:C# NetworkSessionProperties类的具体用法?C# NetworkSessionProperties怎么用?C# NetworkSessionProperties使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NetworkSessionProperties类属于Microsoft.Xna.Framework.Net命名空间,在下文中一共展示了NetworkSessionProperties类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateMatch
public void CreateMatch()
{
if (Gamer.SignedInGamers.Count == 0 && !Guide.IsVisible)
{
Guide.ShowSignIn(1, false);
return;
}
else if (Gamer.SignedInGamers.Count == 0)
{
return;
}
StateManager.NetworkData.LeaveSession();
if (StateManager.NetworkData.AvailableSessions != null)
{
if (!StateManager.NetworkData.AvailableSessions.IsDisposed)
{
StateManager.NetworkData.AvailableSessions.Dispose();
}
StateManager.NetworkData.AvailableSessions = null;
}
LoadingScreen lScr = StateManager.AllScreens[ScreenType.LoadingScreen.ToString()] as LoadingScreen;
lScr.Reset();
lScr.UserCallback = new PGCGame.CoreTypes.Delegates.AsyncHandlerMethod(FinishLanSectorHost);
lScr.LoadingText = "Hosting\n"+(StateManager.NetworkData.SessionType == NetworkSessionType.SystemLink ? "LAN" : "LIVE")+" sector...";
lScr.ScreenFinished += new EventHandler(hosting_finish);
//lScr.ScreenFinished += new EventHandler(lScr_ScreenFinished);
NetworkSessionProperties netSession = new NetworkSessionProperties();
netSession[(int)NetworkSessionPropertyType.SessionType] = (int)StateManager.NetworkData.SessionMode;
NetworkSession.BeginCreate(StateManager.NetworkData.SessionType, new SignedInGamer[] { Gamer.SignedInGamers[0] }, 8, 0, netSession, lScr.Callback, null);
StateManager.ScreenState = CoreTypes.ScreenType.LoadingScreen;
}
示例2: FindSession
public void FindSession(NetworkSessionType sessionType, int maxLocalPlayers, NetworkSessionProperties properties)
{
// all sessions found
AvailableNetworkSessionCollection availableSessions;
// The session we'll join
AvailableNetworkSession availableSession = null;
availableSessions = NetworkSession.Find(sessionType, maxLocalPlayers, properties);
// Get a session with available gamer slots
foreach (AvailableNetworkSession curSession in availableSessions)
{
int TotalSessionSlots = curSession.OpenPublicGamerSlots + curSession.OpenPrivateGamerSlots;
if (TotalSessionSlots > curSession.CurrentGamerCount)
{
availableSession = curSession;
}
}
// if a session was found, connect to it
if (availableSession != null)
{
networkHelper.session = NetworkSession.Join(availableSession);
}
}
示例3: Find
public void Find()
{
NetworkSessionProperties props = new NetworkSessionProperties();
findResult = NetworkSession.BeginFind(NetworkSessionType.SystemLink,
1, props, new AsyncCallback(GotResult), null);
PendingFind = true;
}
示例4: Host
public void Host()
{
if (netPlay.NetSession != null)
netPlay.NetSession.Dispose();
NetworkSessionProperties props = new NetworkSessionProperties();
createResult = NetworkSession.BeginCreate(NetworkSessionType.SystemLink,
1, 2, 0, props, new AsyncCallback(GotResult), null);
PendingHost = true;
}
示例5: ConvertFromLiveSessionProperties
/// <summary>
/// Converts a NetworkSessionProperties instance to the SessionProperties
/// </summary>
internal static SessionProperties ConvertFromLiveSessionProperties(NetworkSessionProperties networkSessionProperties)
{
if (networkSessionProperties == null)
return null;
var sessionProperties = new SessionProperties();
for (int i = 0; i < networkSessionProperties.Count; i++)
{
sessionProperties[i] = networkSessionProperties[i];
}
return sessionProperties;
}
示例6: ConvertToLiveSessionProperties
/// <summary>
/// Converts a SessionProperties instance to the NetworkSessionProperties
/// </summary>
internal static NetworkSessionProperties ConvertToLiveSessionProperties(SessionProperties sessionProperties)
{
if (sessionProperties == null)
return null;
var networkSessionProperties = new NetworkSessionProperties();
for (int i = 0; i < sessionProperties.Count; i++)
{
networkSessionProperties[i] = sessionProperties[i];
}
return networkSessionProperties;
}
示例7: CreateSession
public void CreateSession(NetworkSessionType sessionType, int maxLocalPlayers, int maxGamers,
int privateSlots, NetworkSessionProperties properties)
{
if (networkHelper.session == null)
{
networkHelper.session = NetworkSession.Create(sessionType, maxLocalPlayers,
maxGamers, privateSlots, properties);
// If the host goes out, another machine will asume as a new host
networkHelper.session.AllowHostMigration = true;
// Allow players to join a game in progress
networkHelper.session.AllowJoinInProgress = true;
eventHandler.HookSessionEvents();
}
}
示例8: CreateNetwork
/// <summary>
///
/// </summary>
/// <returns></returns>
public IAsyncResult CreateNetwork(Game game, NetworkSessionType sessionType, int maxLocalGamers, int maxGamers, int privateGamerSlots, NetworkSessionProperties sessionProperties, bool AllowHostMigration, bool AllowJoinInProgress)
{
SessionManager sessionManager = new SessionManager(game);
IAsyncResult asyncResult = sessionManager.CreateSession(sessionType, maxLocalGamers, maxGamers, privateGamerSlots, sessionProperties);
/*
if (networkHelper.NetworkGameSession != null)
{
if (AllowHostMigration == true)
networkHelper.NetworkGameSession.AllowHostMigration = true;
if (AllowJoinInProgress == true)
networkHelper.NetworkGameSession.AllowJoinInProgress = true;
return asyncResult;
}
else
{
//throw new Exception("Session was not Created");
return asyncResult;
}*/
return asyncResult;
}
示例9: Create
public static NetworkSession Create (
NetworkSessionType sessionType, // Type of session being hosted.
IEnumerable<SignedInGamer> localGamers, // Maximum number of local players on the same gaming machine in this network session.
int maxGamers, // Maximum number of players allowed in this network session. For Zune-based games, this value must be between 2 and 8; 8 is the maximum number of players supported in the session.
int privateGamerSlots, // Number of reserved private session slots created for the session. This value must be less than maximumGamers.
NetworkSessionProperties sessionProperties // Properties of the session being created.
)
{
try
{
if ( maxGamers < 2 || maxGamers > 8 )
throw new ArgumentOutOfRangeException( "Maximum number of gamers must be between 2 and 8." );
if ( privateGamerSlots < 0 || privateGamerSlots > maxGamers )
throw new ArgumentOutOfRangeException( "Private session slots must be between 0 and maximum number of gamers." );
networkSessionType = sessionType;
throw new NotImplementedException();
}
finally
{
}
}
示例10: Create
public static NetworkSession Create(NetworkSessionType sessionType, int maxLocalGamers, int maxGamers, int privateGamerSlots, NetworkSessionProperties sessionProperties)
{
return NetworkSession.EndCreate(NetworkSession.BeginCreate(sessionType, maxLocalGamers, maxGamers, privateGamerSlots, sessionProperties, (AsyncCallback) null, (object) null));
}
示例11: BeginFind
private static IAsyncResult BeginFind(NetworkSessionType sessionType, int hostGamer, int maxLocalGamers, NetworkSessionProperties searchProperties, AsyncCallback callback, object asyncState)
{
if (sessionType == NetworkSessionType.Local)
throw new ArgumentException("NetworkSessionType cannot be NetworkSessionType.Local");
if (maxLocalGamers < 1 || maxLocalGamers > 4)
throw new ArgumentOutOfRangeException("maxLocalGamers must be between 1 and 4.");
else
return new NetworkSessionAsynchronousFind(NetworkSession.Find).BeginInvoke(sessionType, hostGamer, maxLocalGamers, searchProperties, callback, asyncState);
}
示例12: BeginCreate
public static IAsyncResult BeginCreate(NetworkSessionType sessionType, IEnumerable<SignedInGamer> localGamers, int maxGamers, int privateGamerSlots, NetworkSessionProperties sessionProperties, AsyncCallback callback, object asyncState)
{
int hostingGamerIndex = NetworkSession.GetHostingGamerIndex(localGamers);
return NetworkSession.BeginCreate(sessionType, hostingGamerIndex, 4, maxGamers, privateGamerSlots, sessionProperties, callback, asyncState);
}
示例13: RefreshAvailableSessions
/// <summary>
/// Refreshes the current list of available sessions.
/// </summary>
/// <param name="searchParameters">Optional parameters to filter by.</param>
public static void RefreshAvailableSessions(NetworkSessionProperties searchParameters = null)
{
AvailableSessions.Clear();
if (HasActiveSession || availableAsync != null)
return;
availableAsync = null;
try
{
AvailableNetworkSessionCollection availableSessions
= NetworkSession.Find(NetworkSessionType.SystemLink, MaxLocalGamers, searchParameters);
foreach (AvailableNetworkSession session in availableSessions)
AvailableSessions.Add(new AvailableSession(session));
}
catch (Exception e)
{
ReportError(e.Message);
}
}
示例14: RefreshAvailableSessionsAsync
/// <summary>
/// Refreshes the current list of available sessions asynchronously.
/// </summary>
/// <param name="searchParameters">Optional parameters to filter by.</param>
public static void RefreshAvailableSessionsAsync(NetworkSessionProperties searchParameters, Action<bool> callback)
{
if (HasActiveSession || availableAsync != null)
{
if ( callback != null )
callback(false);
return;
}
availableCallback = callback;
try
{
availableAsync = NetworkSession.BeginFind(NetworkSessionType.SystemLink, MaxLocalGamers, searchParameters, AvailableAsyncFinished, null);
}
catch (Exception e)
{
ReportError(e.Message);
if ( availableCallback != null )
availableCallback(false);
AvailableAsyncClear();
}
}
示例15: CreateSession
/// <summary>
/// Creates a session with the given parameters.
/// </summary>
/// <param name="maxGamers">Maximum number of gamers allowed.</param>
/// <param name="allowHostMigration">If host migration is allowed.</param>
/// <param name="properties">Properties to initialize the session with.</param>
/// <param name="initializeFunction">The optional function to call to initialize the session.</param>
public static bool CreateSession(int maxGamers, bool allowHostMigration, NetworkSessionProperties properties, ActiveSession.ActiveSessionDelegate initializeFunction )
{
if (IsLocked)
return false;
#if DEBUG
Log.Trace("Creating session...", 2.0f);
#endif
try
{
NetworkSession session = NetworkSession.Create(NetworkSessionType.SystemLink, MaxLocalGamers, maxGamers, 0, properties);
session.AllowHostMigration = allowHostMigration;
ActiveSession = new ActiveSession(session, initializeFunction);
return true;
}
catch( Exception e)
{
ReportError(e.Message);
ActiveSession.EndSession();
return false;
}
}