Tuesday, December 4, 2007

System Link Support - Phase 2: Searching for session

To support both types of network modes is easy, all we have to do is modify the SearchScreen.cs constructor to allow passing in of NetworkSessionType, and then check which type of network session has been passed in and search depending on that:

NetworkSessionType networkSessionType;

public SearchScreen(NetworkSessionType networkSessionType)
{
this.networkSessionType = networkSessionType;

NetworkSessionProperties searchProperties = new NetworkSessionProperties();

if (this.networkSessionType == NetworkSessionType.PlayerMatch)
{
LIVESearch = NetworkSession.BeginFind(NetworkSessionType.PlayerMatch, maxLocalPlayers, searchProperties,
new AsyncCallback(SessionsFound), null);
}
if (this.networkSessionType == NetworkSessionType.SystemLink)
{
LIVESearch = NetworkSession.BeginFind(NetworkSessionType.SystemLink, maxLocalPlayers, searchProperties,
new AsyncCallback(SessionsFound), null);
}
}

Finally go back to the XboxLiveScreen.cs and edit the OnSelectEntry function and modify this line under case 1:
ScreenManager.AddScreen();
to:
ScreenManager.AddScreen(new SearchScreen(networkSessionType));
And thats it.

Other good news is that the new Dashboard Update released today will now be able to show your XNA 2.0 games amongst your other games (so you can fire it up without having to first open the XNA Game Launcher like before) here is the official link.

No comments: