Joining an In-Progress Game

Describes how to enable the AllowJoinInProgress property to make an in-progress game available to peers searching for available sessions.

The Complete Sample

The code in the topic shows you the technique. You can download a complete code sample for this topic, including full source code and any additional supporting files required by the sample.

Download NetworkingSample.

Joining an In-Progress Game

To join an in-progress game

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

    int maximumGamers = 8;  
    int privateGamerSlots = 2;
    int maximumLocalPlayers = 1;
    
    // Create the session
    session = NetworkSession.Create( 
        NetworkSessionType.SystemLink,
        maximumLocalPlayers, maximumGamers, privateGamerSlots, 
        sessionProperties );
    
    session.AllowJoinInProgress = true;
    

    In the NetworkSession.GamerJoined event handler, the gamer may be a player who joined an in-progress game.

  2. Associate any data necessary to enable 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, GraphicsDevice.PresentationParameters);
    
    }
    

Note

Network sessions of type NetworkSessionType.Ranked cannot be made join-in-progress because of the competitive nature of ranked sessions.

See Also

Concepts

Network Session Management

Tasks

Joining and Leaving a Game
Finding and Joining a Network Session