Пример #1
0
 /// <summary>
 /// Attempts to join a session.
 /// </summary>
 /// <param name="session">The AvailableSession to join.</param>
 /// <param name="initializeFunction">The optional function to call to initialize the session.</param>
 public static bool JoinSession(AvailableSession session, ActiveSession.ActiveSessionDelegate initializeFunction)
 {
     if (IsLocked)
         return false;
     #if DEBUG
     Log.Trace(String.Format("Joining session hosted by {0}...", session.HostName), 2.0f);
     #endif
     try
     {
         NetworkSession newSession = NetworkSession.Join(session.NativeSession);
         ActiveSession = new ActiveSession(newSession, initializeFunction);
         return true;
     }
     catch (Exception e)
     {
         ReportError(e.Message);
         ActiveSession.EndSession();
         return false;
     }
 }
Пример #2
0
 /// <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;
     }
 }