public void SearchForGame()
        {
            if (Gamer.SignedInGamers.Count == 0)
            {
                SignIn();
            }
            else
            {
                if (_session != null)
                {
                    _session.Dispose();
                }
                AvailableNetworkSessionCollection sessions = NetworkSession.Find(NetworkSessionType.SystemLink, 1, null);
                if (sessions.Count > 0)
                {
                    try
                    {
                        AvailableNetworkSession mySession = sessions[0];
                        _session            = NetworkSession.Join(mySession);
                        _session.GamerLeft += new EventHandler <GamerLeftEventArgs>(Client_GamerLeft);

                        GameMain.ChangeState(GameState.PlayingClient);

                        IsHost = false;
                    }
                    catch (Exception ex)
                    {
                        // Not the best solution, but...
                        GameMain.ChangeState(GameState.TitleScreen);
                    }
                }
            }
        }
Exemplo n.º 2
0
        void joinSession_Pressed(object sender, EventArgs e)
        {
            if (!Guide.IsVisible && !allScreens["chatScreen"].Visible)
            {
                availableSessions = NetworkSession.Find(
                    NetworkSessionType.SystemLink, 2,
                    null);
                allScreens["listSessions"].Visible = true;
                allScreens["titleScreen"].Visible  = false;
                allScreens["listSessions"].AdditionalSprites.RemoveAll(ts => !(ts is TextSprite) || ts.Cast <TextSprite>().HoverColor != Color.LimeGreen);
                float y = 50;
                float x = 100;
                for (int sessionIndex = 0; sessionIndex < availableSessions.Count; sessionIndex++)
                {
                    AvailableNetworkSession availableSession =
                        availableSessions[sessionIndex];

                    string             HostGamerTag    = availableSession.HostGamertag;
                    int                GamersInSession = availableSession.CurrentGamerCount;
                    SessionInfoDisplay info            = new SessionInfoDisplay(spriteBatch, new Vector2(x, y), font, HostGamerTag + ": " + GamersInSession + "/2 gamers", availableSession);
                    info.IsHoverable   = true;
                    info.NonHoverColor = Color.Black;
                    info.HoverColor    = Color.White;
                    info.Pressed      += new EventHandler(info_Pressed);
                    allScreens["listSessions"].AdditionalSprites.Add(info);
                }
            }
        }
Exemplo n.º 3
0
 /* Call this internally when a connection to a given available session is desired.
  */
 protected virtual void ConnectToSession(AvailableNetworkSession sess)
 {
     Trace.WriteLine("Connecting to session host: {0}", sess.HostGamertag);
     Debug.Assert(joinAsync_ == null);
     joinAsync_ = NetworkSession.BeginJoin(sess, OnSessionConnected, null);
     Debug.Assert(joinAsync_.CompletedSynchronously == false);
 }
Exemplo n.º 4
0
        public void SortSessions()
        {
            AvailableNetworkSession BestSession = null;
            double BestQuality = 1000000000;


            foreach (AvailableNetworkSession session in availableSessions)
            {
                double Val = session.QualityOfService.AverageRoundtripTime.TotalMilliseconds;
                if (Val < BestQuality)
                {
                    BestQuality = Val;
                    BestSession = session;
                }
            }
            if (BestSession != null)
            {
                JoinSession(BestSession);
            }
            else
            {
                CreateGame();
            }

            IsSearching = false;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Event handler for when an available session menu entry is selected.
        /// </summary>
        void AvailableSessionMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            // Which menu entry was selected?
            AvailableSessionMenuEntry menuEntry        = (AvailableSessionMenuEntry)sender;
            AvailableNetworkSession   availableSession = menuEntry.AvailableSession;

            try
            {
                // Begin an asynchronous join network session operation.
                IAsyncResult asyncResult = NetworkSession.BeginJoin(availableSession,
                                                                    null, null);

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

                busyScreen.OperationCompleted += JoinSessionOperationCompleted;

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

                ScreenManager.AddScreen(errorScreen, ControllingPlayer);
            }
        }
Exemplo n.º 6
0
        public void FindSession()
        {
            // all sessions found
            AvailableNetworkSessionCollection availableSessions;
            // the session we'll join
            AvailableNetworkSession availableSession = null;

            availableSessions = NetworkSession.Find(NetworkSessionType.SystemLink,
                                                    maximumLocalPlayers, null);
            // 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)
            {
                message = "Found an available session at host " +
                          availableSession.HostGamertag;
                session = NetworkSession.Join(availableSession);
            }
            else
            {
                message = "No sessions found!";
            }
        }
Exemplo n.º 7
0
    public void FindSession()
    {
        // All sessions found
        AvailableNetworkSessionCollection availableSessions;
        // The session we'll join
        AvailableNetworkSession availableSession = null;

        availableSessions = NetworkSession.Find(NetworkSessionType.SystemLink, maximumLocalPlayers, null);

        // Get a session with available gamer slots
        foreach (AvailableNetworkSession curSession in availableSessions)
        {
            Console.WriteLine("FindSession() foreach");
            int TotalSessionSlots = curSession.OpenPublicGamerSlots + curSession.OpenPrivateGamerSlots;

            if (TotalSessionSlots > curSession.CurrentGamerCount)
            {
                Console.WriteLine("FindSession() totalsessionslots");
                availableSession = curSession;
            }
        }

        // If session was found, connect to it
        if (availableSession != null)
        {
            Console.WriteLine("findsession() availablesession");
            message   = "Found an available session at host " + availableSession.HostGamertag;
            session   = NetworkSession.Join(availableSession);
            gameStart = true;
        }
        else
        {
            message = "No sessions found.";
        }
    }
Exemplo n.º 8
0
        public virtual void JustFindSessions()
        {
            sayMessage("Calling JustFindSessions()");
            AvailableNetworkSessionCollection availableSessions;
            int maximumLocalPlayers = 1;

            availableSessions = NetworkSession.Find(
                NetworkSessionType.SystemLink, maximumLocalPlayers, null);
            try
            {
                int sessionIndex = 0;
                AvailableNetworkSession availableSession = availableSessions[sessionIndex];


                string HostGamerTag          = availableSession.HostGamertag;
                int    GamersInSession       = availableSession.CurrentGamerCount;
                int    OpenPrivateGamerSlots = availableSession.OpenPrivateGamerSlots;
                int    OpenPublicGamerSlots  = availableSession.OpenPublicGamerSlots;
                string sessionInformation    = "Session available from gamertag " + HostGamerTag +
                                               "\n" + GamersInSession + " players already in this session. \n" +
                                               +OpenPrivateGamerSlots + " open private player slots available. \n" +
                                               +OpenPublicGamerSlots + " public player slots available.";
                JustFindSessionsResult = sessionInformation;
            }
            catch
            {
                sayMessage("Error in JustFindSessions()");
            }
        }
Exemplo n.º 9
0
        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);
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Formats session information to create the menu text string.
        /// </summary>
        static string GetMenuItemText(AvailableNetworkSession session)
        {
            int totalSlots = session.CurrentGamerCount +
                             session.OpenPublicGamerSlots;

            return(string.Format("{0} ({1}/{2})", session.HostGamertag,
                                 session.CurrentGamerCount,
                                 totalSlots));
        }
Exemplo n.º 11
0
        public List <IAvailableNetworkSession> FindSessions(SessionMatching match)
        {
            var sess = new AvailableNetworkSession(NetworkSessionType.PlayerMatch, "Hello");

            sess.QualityOfService = new QualityOfService();
            var result = new List <IAvailableNetworkSession>();

            result.Add(sess);
            return(result);
        }
Exemplo n.º 12
0
        public void JoinSession(AvailableNetworkSession session)
        {
            IsJoining = false;

            networkSession = NetworkSession.Join(session);

            HookSessionEvents();

            BeginOnlineGameAsGuest();
        }
Exemplo n.º 13
0
 /// <summary>
 /// Begins to asynchronously join the specified <see cref="AvailableNetworkSession"/>.
 /// </summary>
 /// <param name="toJoin">The session to join.</param>
 public void JoinSession(AvailableNetworkSession toJoin)
 {
     if (toJoin == null)
     {
         throw new ArgumentNullException("toJoin");
     }
     if (_asyncSessionOperationsInProgress > 0)
     {
         throw new InvalidOperationException("An asynchronous session operation is already in progress.");
     }
     _asyncSessionOperationsInProgress++;
     NetworkSession.BeginJoin(toJoin, NetSessionJoin, null);
 }
Exemplo n.º 14
0
 public void JoinSession(AvailableNetworkSession Session)
 {
     try
     {
         _netSession = NetworkSession.Join(Session);
     }
     catch
     {
         return;
     }
     _isClient = true;
     initialiseEventHandlers();
 }
Exemplo n.º 15
0
        /* Completion of looking for sessions.
         */
        protected virtual void OnSessionsFound(IAsyncResult ar)
        {
            findAsync_ = null;
            AvailableNetworkSessionCollection availableSessions = NetworkSession.EndFind(ar);

            if (availableSessions.Count != 0)
            {
                /* Pick one of the available sessions.
                 */
                List <AvailableNetworkSession> toChooseFrom = new List <AvailableNetworkSession>();
                Trace.WriteLine(String.Format("Found {0} potential network sessions.", availableSessions.Count));
                foreach (AvailableNetworkSession ans in availableSessions)
                {
                    if (ans.OpenPublicGamerSlots < saveLocalPlayerCount &&
                        ans.OpenPublicGamerSlots < SignedInGamer.SignedInGamers.Count)
                    {
                        //  full
                        continue;
                    }
                    if (sessionType != SessionType.HighscoresOnly || !previousSessionHosts.Member(ans.HostGamertag))
                    {
                        //  this seems like an OK session, use that!
                        toChooseFrom.Add(ans);
                    }
                }
                if (toChooseFrom.Count > 0)
                {
                    //  pick one at random
                    AvailableNetworkSession ans = toChooseFrom[rand.Next(toChooseFrom.Count)];
                    previousSessionHosts.Add(ans.HostGamertag);
                    Trace.WriteLine(String.Format("Connecting to session hosted by '{0}'", ans.HostGamertag));
                    ConnectToSession(ans);
                    return;
                }
                else
                {
                    /* I went through all the possible sessions, so now I can re-start looking
                     * at hosts I've previously talked to.
                     */
                    previousSessionHosts.Clear();
                }
            }
            //  OK, nothing matched -- try to create something for others to find
            Trace.WriteLine("Creating session because no available session was suitable.");
            Debug.Assert(createAsync_ == null);
            createAsync_ = NetworkSession.BeginCreate(netType, saveLocalPlayerCount, saveTotalPlayerCount,
                                                      0, saveProps, OnSessionCreated, null);
            Debug.Assert(createAsync_.CompletedSynchronously == false);
        }
Exemplo n.º 16
0
        void info_Pressed(object sender, EventArgs e)
        {
            if (!Guide.IsVisible && !allScreens["chatScreen"].Visible)
            {
                AvailableNetworkSession asession = sender.Cast <SessionInfoDisplay>().Session;

                IAsyncResult beginJoinSess = NetworkSession.BeginJoin(asession, null, null);
                beginJoinSess.AsyncWaitHandle.WaitOne();

                this.session         = NetworkSession.EndJoin(beginJoinSess);
                session.GamerJoined += new EventHandler <GamerJoinedEventArgs>(session_GamerJoined);
                session.GameStarted += new EventHandler <GameStartedEventArgs>(session_GameStarted);
                Services.AddService(typeof(NetworkSession), session);
            }
        }
Exemplo n.º 17
0
    public void session_SessionFound(IAsyncResult result)
    {
        // All sessions found
        AvailableNetworkSessionCollection availableSessions;
        // The session we will join
        AvailableNetworkSession availableSession = null;

        if (AsyncSessionFind.IsCompleted)
        {
            Console.WriteLine("AsyncSessionFind.IsCompleted");
            availableSessions = NetworkSession.EndFind(result);

            // Look for a session with available gamer slots
            foreach (AvailableNetworkSession curSession in availableSessions)
            {
                Console.WriteLine("foreach");
                int TotalSessionSlots = curSession.OpenPublicGamerSlots + curSession.OpenPrivateGamerSlots;

                if (TotalSessionSlots > curSession.CurrentGamerCount)
                {
                    Console.WriteLine("TotalSessionSlots");
                    availableSession = curSession;
                }
            }

            // If a session was found, connect to it
            if (availableSession != null)
            {
                message = "Found an available session at host " + availableSession.HostGamertag;
                session = NetworkSession.Join(availableSession);
            }
            else
            {
                message = "No sessions found.";
            }
            // Reset the session finding result
            AsyncSessionFind = null;
        }
    }
        private void EndAsynchSearch(IAsyncResult result)
        {
            AvailableNetworkSessionCollection activeSessions = NetworkSession.EndFind(result);

            if (activeSessions.Count == 0)
            {
                currentGameState = GameState.CreateSession;
                log.Add("No active sessions found - proceed to CreateSession");
            }
            else
            {
                AvailableNetworkSession sessionToJoin = activeSessions[0];
                networkSession = NetworkSession.Join(sessionToJoin);

                string myString = "Joined session hosted by " + sessionToJoin.HostGamertag;
                myString += " with " + sessionToJoin.CurrentGamerCount.ToString() + " players";
                myString += " and " + sessionToJoin.OpenPublicGamerSlots.ToString() + " open player slots.";
                log.Add(myString);

                HookSessionEvents();
                currentGameState = GameState.InSession;
            }
        }
Exemplo n.º 19
0
        public virtual void session_SessionFound(IAsyncResult result)
        {
            // all sessions found
            AvailableNetworkSessionCollection availableSessions;
            // the session we will join
            AvailableNetworkSession availableSession = null;

            if (AsyncSessionFind.IsCompleted)
            {
                availableSessions = NetworkSession.EndFind(result);
                // Look for 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)
                {
                    sayMessage("Found an available session at host" +
                               availableSession.HostGamertag);
                    Session = NetworkSession.Join(availableSession);
                }
                else
                {
                    sayMessage("No sessions found!");
                }
                //  Reset the session finding result
                AsyncSessionFind = null;
            }
        }
        protected override void Update(GameTime gameTime)
        {
            GamePadState padState = GamePad.GetState(PlayerIndex.One);

            if (padState.Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }

            KeyboardState keybState = Keyboard.GetState();

            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:
                {
                    NetworkSessionProperties findProperties = new NetworkSessionProperties();
                    findProperties[0] = 3;
                    findProperties[1] = 4096;

                    AvailableNetworkSessionCollection activeSessions = NetworkSession.Find(NetworkSessionType.SystemLink, 4, findProperties);
                    if (activeSessions.Count == 0)
                    {
                        currentGameState = GameState.CreateSession;
                        log.Add("No active sessions found - proceed to CreateSession");
                    }
                    else
                    {
                        AvailableNetworkSession sessionToJoin = activeSessions[0];
                        networkSession = NetworkSession.Join(sessionToJoin);

                        string myString = "Joined session hosted by " + sessionToJoin.HostGamertag;
                        myString += " with " + sessionToJoin.CurrentGamerCount.ToString() + " players";
                        myString += " and " + sessionToJoin.OpenPublicGamerSlots.ToString() + " open player slots.";
                        log.Add(myString);

                        HookSessionEvents();
                        command          = "[Press X to signal you're ready]";
                        currentGameState = GameState.InSession;
                    }
                }
                break;

                case GameState.CreateSession:
                {
                    NetworkSessionProperties createProperties = new NetworkSessionProperties();
                    createProperties[0] = 3;
                    createProperties[1] = 4096;

                    networkSession = NetworkSession.Create(NetworkSessionType.SystemLink, 4, 16, 0, createProperties);
                    networkSession.AllowHostMigration  = true;
                    networkSession.AllowJoinInProgress = false;
                    log.Add("New session created");

                    HookSessionEvents();

                    command          = "[Press X to signal you're ready]";
                    currentGameState = GameState.InSession;
                }
                break;

                case GameState.InSession:
                {
                    switch (networkSession.SessionState)
                    {
                    case NetworkSessionState.Lobby:
                    {
                        if ((keybState != lastKeybState) || (padState != lastPadState))
                        {
                            if (keybState.IsKeyDown(Keys.X) || (padState.IsButtonDown(Buttons.X)))
                            {
                                LocalNetworkGamer localGamer = networkSession.LocalGamers[0];
                                localGamer.IsReady = !localGamer.IsReady;
                            }
                        }

                        if (networkSession.IsHost)
                        {
                            if (networkSession.AllGamers.Count > 1)
                            {
                                if (networkSession.IsEveryoneReady)
                                {
                                    networkSession.StartGame();
                                    log.Add("All players ready -- start the game!");
                                }
                            }
                        }
                    }
                    break;

                    case NetworkSessionState.Playing:
                    {
                        if (networkSession.IsHost)
                        {
                            if ((keybState != lastKeybState) || (padState != lastPadState))
                            {
                                if (keybState.IsKeyDown(Keys.Y) || (padState.IsButtonDown(Buttons.Y)))
                                {
                                    networkSession.EndGame();
                                }
                            }
                        }
                    }
                    break;
                    }

                    networkSession.Update();
                }
                break;
                }
            }

            lastKeybState = keybState;

            base.Update(gameTime);
        }
Exemplo n.º 21
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);
 }
Exemplo n.º 22
0
 public SessionInfoDisplay(SpriteBatch s, Vector2 v, SpriteFont f, string t, AvailableNetworkSession sess)
     : base(s, v, f, t)
 {
     Session = sess;
 }
Exemplo n.º 23
0
 /// <summary>
 /// Constructs a menu entry describing an available network session.
 /// </summary>
 public AvailableSessionMenuEntry(AvailableNetworkSession availableSession)
     : base(GetMenuItemText(availableSession))
 {
     this.availableSession = availableSession;
 }
        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:
                {
                    AvailableNetworkSessionCollection activeSessions = NetworkSession.Find(NetworkSessionType.SystemLink, 4, null);
                    if (activeSessions.Count == 0)
                    {
                        currentGameState = GameState.CreateSession;
                        log.Add("No active sessions found - proceed to CreateSession");
                    }
                    else
                    {
                        AvailableNetworkSession sessionToJoin = activeSessions[0];
                        networkSession = NetworkSession.Join(sessionToJoin);

                        string myString = "Joined session hosted by " + sessionToJoin.HostGamertag;
                        myString += " with " + sessionToJoin.CurrentGamerCount.ToString() + " players";
                        myString += " and " + sessionToJoin.OpenPublicGamerSlots.ToString() + " open player slots.";
                        log.Add(myString);

                        HookSessionEvents();
                        currentGameState = GameState.InSession;
                    }
                }
                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:
                {
                    //send data to all other players in session
                    writer.Write(gameTime.TotalGameTime.Minutes);
                    writer.Write(gameTime.TotalGameTime.Seconds);

                    LocalNetworkGamer localGamer = networkSession.LocalGamers[0];
                    localGamer.SendData(writer, SendDataOptions.ReliableInOrder);

                    //receive data from all other players in session
                    while (localGamer.IsDataAvailable)
                    {
                        NetworkGamer sender;
                        localGamer.ReceiveData(reader, out sender);

                        string gamerTime = "";
                        gamerTime += sender.Gamertag + ": ";
                        gamerTime += reader.ReadInt32() + "m ";
                        gamerTime += reader.ReadInt32() + "s";
                        gamerTimes[sender.Gamertag] = gamerTime;
                    }

                    networkSession.Update();
                }
                break;
                }
            }

            base.Update(gameTime);
        }
        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:
                {
                    Gamer.SignedInGamers[0].Presence.PresenceMode  = GamerPresenceMode.Level;
                    Gamer.SignedInGamers[0].Presence.PresenceValue = 15;
                    AvailableNetworkSessionCollection activeSessions = NetworkSession.Find(NetworkSessionType.SystemLink, 4, null);
                    if (activeSessions.Count == 0)
                    {
                        currentGameState = GameState.CreateSession;
                        log.Add("No active sessions found - proceed to CreateSession");
                    }
                    else
                    {
                        AvailableNetworkSession sessionToJoin = activeSessions[0];
                        networkSession = NetworkSession.Join(sessionToJoin);

                        string myString = "Joined session hosted by " + sessionToJoin.HostGamertag;
                        myString += " with " + sessionToJoin.CurrentGamerCount.ToString() + " players";
                        myString += " and " + sessionToJoin.OpenPublicGamerSlots.ToString() + " open player slots.";
                        log.Add(myString);

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

                case GameState.CreateSession:
                {
                    networkSession = NetworkSession.Create(NetworkSessionType.SystemLink, 4, 8);
                    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);
        }
Exemplo n.º 26
0
 public JoinableSession(AvailableNetworkSession session)
 {
     host            = session.HostGamertag;
     players         = session.CurrentGamerCount;
     joinableSession = session;
 }