コード例 #1
0
ファイル: LiveSessionManager.cs プロジェクト: Indiefreaks/igf
        /// <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");
            }
        }
コード例 #2
0
        /// <summary>
        /// Event handler for when the Find Sessions menu entry is selected.
        /// </summary>
        void FindSessionsMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            try
            {
                // Which local profiles should we include in this session?
                IEnumerable <SignedInGamer> localGamers =
                    NetworkSessionComponent.ChooseGamers(sessionType,
                                                         ControllingPlayer.Value);

                // Begin an asynchronous find network sessions operation.
                IAsyncResult asyncResult = NetworkSession.BeginFind(sessionType,
                                                                    localGamers, null, null, null);

                // Activate the network busy screen, which will display
                // an animation until this operation has completed.
                NetworkBusyScreen busyScreen = new NetworkBusyScreen(asyncResult);

                busyScreen.OperationCompleted += FindSessionsOperationCompleted;

                ScreenManager.AddScreen(busyScreen, ControllingPlayer);
            }
            catch (Exception exception)
            {
                NetworkErrorScreen errorScreen = new NetworkErrorScreen(exception);

                ScreenManager.AddScreen(errorScreen, ControllingPlayer);
            }
        }
コード例 #3
0
        /// <summary>
        /// Event handler for when the Find Sessions menu entry is selected.
        /// </summary>
        void FindSessionsMenuEntrySelected(object sender, EventArgs e)
        {
            try
            {
                // Begin an asynchronous find network sessions operation.
                IAsyncResult asyncResult = NetworkSession.BeginFind(sessionType,
                                                                    NetworkSessionComponent.MaxLocalGamers,
                                                                    null, null, null);

                // Activate the network busy screen, which will display
                // an animation until this operation has completed.
                NetworkBusyScreen busyScreen = new NetworkBusyScreen(asyncResult);

                busyScreen.OperationCompleted += FindSessionsOperationCompleted;

                ScreenManager.AddScreen(busyScreen);
            }
            catch (NetworkException exception)
            {
                ScreenManager.AddScreen(new NetworkErrorScreen(exception));
            }
            catch (GamerPrivilegeException exception)
            {
                ScreenManager.AddScreen(new NetworkErrorScreen(exception));
            }
        }
コード例 #4
0
        private void ExecuteRemoteCommand(IDebugCommandHost host, string command,
                                          IList <string> arguments)
        {
            if (NetworkSession == null)
            {
                try
                {
                    GamerServicesDispatcher.WindowHandle = Game.Window.Handle;
                    GamerServicesDispatcher.Initialize(Game.Services);
                }
                catch { }

                if (SignedInGamer.SignedInGamers.Count > 0)
                {
                    commandHost.Echo("Finding available sessions...");

                    asyncResult = NetworkSession.BeginFind(
                        NetworkSessionType.SystemLink, 1, null, null, null);

                    phase = ConnectionPahse.FindSessions;
                }
                else
                {
                    host.Echo("Please signed in.");
                    phase = ConnectionPahse.EnsureSignedIn;
                }
            }
            else
            {
                ConnectedToRemote();
            }
        }
コード例 #5
0
        public void Find()
        {
            NetworkSessionProperties props = new NetworkSessionProperties();

            findResult = NetworkSession.BeginFind(NetworkSessionType.SystemLink,
                                                  1, props, new AsyncCallback(GotResult), null);
            PendingFind = true;
        }
コード例 #6
0
 protected virtual void ActOnSessionTypeDesired()
 {
     /* Kick off a new find of network session information.
      */
     Debug.Assert(findAsync_ == null);
     findAsync_ = NetworkSession.BeginFind(netType, saveLocalPlayerCount, saveProps, OnSessionsFound, null);
     Debug.Assert(findAsync_.CompletedSynchronously == false);
 }
コード例 #7
0
ファイル: NetworkHelper.cs プロジェクト: ARLM-Attic/neat
 public virtual void AsyncFindSession()
 {
     sayMessage("Asynchronous search started!");
     if (AsyncSessionFind == null)
     {
         AsyncSessionFind = NetworkSession.BeginFind(
             NetworkSessionType.SystemLink, 1, null,
             new AsyncCallback(session_SessionFound), null);
     }
 }
コード例 #8
0
        /// <summary>
        /// Begins the process of asynchronously finding <see cref="AvailableNetworkSession"/>s.
        /// </summary>
        /// <param name="type">The type of the <see cref="NetworkSession"/> to find.</param>
        /// <param name="gamers">The maximum number of local gamers to allow within the <see cref="NetworkSession"/>.</param>
        /// <param name="reqProps">The <see cref="NetworkSessionProperties"/> that must be present on the found <see cref="NetworkSession"/>, or null if none.</param>
        public void FindSessions(NetworkSessionType type, int gamers, NetworkSessionProperties reqProps)
        {
            if (_asyncSessionOperationsInProgress > 0)
            {
                throw new InvalidOperationException("An asynchronous session operation is already in progress.");
            }
            _asyncSessionOperationsInProgress++;

            NetworkSession.BeginFind(type, gamers, reqProps, NetSessionsFound, null);
        }
コード例 #9
0
 public void AsyncFindSession()
 {
     message = "Asynchronous search started!";
     if (AsyncSessionFind == null)
     {
         AsyncSessionFind = NetworkSession.BeginFind(
             NetworkSessionType.SystemLink, maximumLocalPlayers, null,
             new AsyncCallback(session_SessionFound), null);
     }
 }
コード例 #10
0
        /// <summary>
        /// Start searching for a session of the given type.
        /// </summary>
        /// <param name="sessionType">The type of session to look for.</param>
        void FindSession(NetworkSessionType sessionType)
        {
            // create the new screen
            SearchResultsScreen searchResultsScreen =
                new SearchResultsScreen(sessionType);

            searchResultsScreen.ScreenManager = this.ScreenManager;
            ScreenManager.AddScreen(searchResultsScreen);

            // start the search
            try
            {
                IAsyncResult asyncResult = NetworkSession.BeginFind(sessionType, 1, null,
                                                                    null, null);

                // create the busy screen
                NetworkBusyScreen busyScreen = new NetworkBusyScreen(
                    "Searching for a session...", asyncResult);
                busyScreen.OperationCompleted += searchResultsScreen.SessionsFound;
                ScreenManager.AddScreen(busyScreen);
            }
            catch (NetworkException ne)
            {
                const string     message    = "Failed searching for the session.";
                MessageBoxScreen messageBox = new MessageBoxScreen(message);
                messageBox.Accepted  += FailedMessageBox;
                messageBox.Cancelled += FailedMessageBox;
                ScreenManager.AddScreen(messageBox);

                System.Console.WriteLine("Failed to search for session:  " +
                                         ne.Message);
            }
            catch (GamerPrivilegeException gpe)
            {
                const string message =
                    "You do not have permission to search for a session.";
                MessageBoxScreen messageBox = new MessageBoxScreen(message);
                messageBox.Accepted  += FailedMessageBox;
                messageBox.Cancelled += FailedMessageBox;
                ScreenManager.AddScreen(messageBox);

                System.Console.WriteLine(
                    "Insufficient privilege to search for session:  " + gpe.Message);
            }
        }
コード例 #11
0
        public void BeginGameSearch()
        {
            if (networkSession == null)
            {
                IsSearching = true;

                SetString("Searching for Games...");

                try
                {
                    FindResult = NetworkSession.BeginFind(SessionType, 4, null, null, null);
                }
                catch (Exception e)
                {
                    // if (networkSession == null)
                    OnlineString = e.Message;
                }
            }
        }
コード例 #12
0
 public static void BeginFindSessions(NetworkSessionType networkSessionType, int p, FindSessionCompleteHandler callback)
 {
     IAsyncResult asyncResult = NetworkSession.BeginFind(networkSessionType,
                                                         p,
                                                         null, new AsyncCallback(FindSessionsComplete), callback);
 }
コード例 #13
0
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }

            if (this.IsActive)
            {
                switch (currentGameState)
                {
                case GameState.SignIn:
                {
                    if (Gamer.SignedInGamers.Count < 1)
                    {
                        Guide.ShowSignIn(1, false);
                        log.Add("Opened User SignIn Interface");
                    }
                    else
                    {
                        currentGameState = GameState.SearchSession;
                        log.Add(Gamer.SignedInGamers[0].Gamertag + " logged in - proceed to SearchSession");
                    }
                }
                break;

                case GameState.SearchSession:
                {
                    NetworkSession.BeginFind(NetworkSessionType.SystemLink, 2, null, EndAsynchSearch, null);
                    log.Add("ASynch search started - proceed to Searching");
                    log.Add("Searching");
                    currentGameState = GameState.Searching;
                }
                break;

                case GameState.Searching:
                {
                    log[log.Count - 1] += ".";
                }
                break;

                case GameState.CreateSession:
                {
                    networkSession = NetworkSession.Create(NetworkSessionType.SystemLink, 4, 16);
                    networkSession.AllowHostMigration  = true;
                    networkSession.AllowJoinInProgress = false;
                    log.Add("New session created");

                    HookSessionEvents();
                    currentGameState = GameState.InSession;
                }
                break;

                case GameState.InSession:
                {
                    networkSession.Update();
                }
                break;
                }
            }

            base.Update(gameTime);
        }