How To: Join an In-Progress Game

To Join an In-Progress Game

  1. After creating a NetworkSession, set AllowJoinInProgress to true.

    int maximumGamers = 8;  // The maximum supported is 31
    int privateGamerSlots = 2;
    int maximumLocalPlayers = 1;
    // Create the session
    session = NetworkSession.Create( 
        maximumLocalPlayers, maximumGamers, privateGamerSlots, 
        sessionProperties );
    session.AllowJoinInProgress = true;
  2. In the NetworkSession.GamerJoined event handler, the gamer may be a gamer that has joined an in-progress game. Associate any data necessary to allow for a gamer to join while the game is in-progress.

    void session_GamerJoined(object sender, GamerJoinedEventArgs e)
        // Associate a tank object with this gamer.
        e.Gamer.Tag = new Tank(Content, graphics.GraphicsDevice.PresentationParameters);
Network sessions of type NetworkSessionType.Ranked cannot be made join-in-progress, due to the competive nature of ranked sessions.

Community Additions