Helper methods to convert SessionProperties to and from NetworkSessionProperties
Esempio n. 1
0
        /// <summary>
        /// Sends a Find query on the network interface to look for AvailableSession instances asynchrnously
        /// </summary>
        /// <param name="sessionType">The SessionType we're looking for</param>
        /// <param name="maxLocalPlayers">The Maximum local players that can be added to the session used to filter sessions that have a limited number of opened public slots</param>
        /// <param name="sessionProperties">The SessionProperties that will be used to filter query results. Can be null</param>
        public override void FindSessions(SessionType sessionType, int maxLocalPlayers,
                                          SessionProperties sessionProperties)
        {
            _networkSessionLocker = FindingSessions;
            switch (sessionType)
            {
            case SessionType.WideAreaNetwork:
            {
                NetworkSession.BeginFind(NetworkSessionType.PlayerMatch, maxLocalPlayers,
                                         LiveSessionProperties.ConvertToLiveSessionProperties(sessionProperties),
                                         OnLiveSessionsFound,
                                         _networkSessionLocker);
                break;
            }

            case SessionType.LocalAreaNetwork:
            {
                NetworkSession.BeginFind(NetworkSessionType.SystemLink, maxLocalPlayers,
                                         LiveSessionProperties.ConvertToLiveSessionProperties(sessionProperties),
                                         OnLiveSessionsFound, _networkSessionLocker);
                break;
            }

            default:
            case SessionType.SplitScreen:
            case SessionType.SinglePlayer:
                throw new CoreException("Cannot look for a Device only session");
            }
        }
Esempio n. 2
0
        /// <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)
        {
            if (LocalPlayers.Count > 1)
            {
                throw new NotImplementedException();
            }
            if (CurrentSession != null)
            {
                throw new CoreException("A session already exists. Close the previous session first");
            }

            _networkSessionLocker = CreatingSession;

            NetworkSession.BeginCreate(NetworkSessionType.PlayerMatch, 1, maxPlayers, 0,
                                       LiveSessionProperties.ConvertToLiveSessionProperties(sessionProperties),
                                       OnLiveSessionCreated, _networkSessionLocker);
        }
Esempio n. 3
0
 /// <summary>
 /// Creates a new instance
 /// </summary>
 /// <param name="availableSession">The Xbox Live AvailableNetworkSession instance</param>
 internal LiveAvailableSession(AvailableNetworkSession availableSession)
 {
     AvailableNetworkSession = availableSession;
     _sessionProperties      =
         LiveSessionProperties.ConvertFromLiveSessionProperties(availableSession.SessionProperties);
 }