EDIT: RESOLVED! …by myself …by something stupid:
___________________________________________
The Question: How come I never get a list of games returned for MatchMaking (in the lobby)?
$25 PayPal (or Google Wallet) bounty for an answer (Unity devs, too)! Must use the new-ish NetworkLobbyManager component/class. For the $25, I must test working. Best working answer wins.
TL;DR flow:
- Click a btn, start matchmaking. // StartMatchMaker appears to have sync issues?
- List matches
- No match? Create a game.
- Match? Join a game.
What happens when I test:
- “A” launches game and clicks MMBtn.
- “A” match list found no matches, so created a game.
- “B” launches game and clicks MMBtn.
- “B” match list found no matches, so created a game // Should have found 1 match
- Both are awkwardly waiting, when B SHOULD have joined A’s game).
- Both hosts have the same networkId, hinting sync/instance issues.
Code flow (apologies for typos, not copy+pasting for simplicity):
public class myLobbyScript : NetworkLobbyManager {
[SerializeField] NetworkLobbyManager lobbyMgr
...
// ........................................................
void calledFromBtnClick()
{
lobbyMgr.StartMatchMaker();
lobbyMgr.matchMaker.ListMatches(0, 20, "", true, 0, 0, OnMatchList);
// Issue starts @ callback above?
}
// ........................................................
public override void OnMatchList(bool success, string extendedInfo, List<MatchInfoSnapshot> matchList)
{
If (matchList.Count <= 0) // No match found, create match (ALWAYS 0 matches)
{
lobbyMgr.matchMaker.CreateMatch(
"MM", 15, true, "", Network.player.externalIP, Network.player.ipAddress,
0, 1, OnMatchCreate);
}
else
{
// Match found, join match
MatchInfoSnapshot firstMatchFound = matchList[0];
lobbyMgr.matchMaker.JoinMatch(
firstMatchFound.networkId, "", Network.player.externalIP,
Network.player.ipAddress, 0, 0);
}
}
// ........................................................
public override void OnMatchCreate(bool success, string extendedInfo, MatchInfo matchInfo)
{
Debug.Log("@ OnMatchCreate");
}
// ........................................................
public override void OnMatchJoined(bool success, string extendedInfo, MatchInfo matchInfo)
{
Debug.Log("@ OnMatchJoined");
}
NOTES:
- The script attached to the NetworkLobbyManager component’s parent gameObj is called myLobbyMgr and is derived from NetworkLobbyManager (I tried Mono, and can do everything by lobbyMgr.Whatever EXCEPT for overrides. However, when I override, it seems to make things out-of-sync.
- Found this bitbucket with obsolete code, but a hint, nonetheless.
- My Unity Answers post is here with more info than you probably want (trial+err results)
- Ultimately, I feel that the issue is caused with the callbacks. The docs (AND the bitbucket src for the NetworkGUI), although old, put the callback param as lobbyMgr.OnMatchList - however, there is NO WAY (that I know of) to actually catch that specific instance: it doesn’t seem to be sync’d with the standard override from the NetworkLobbyManager class, but only with the object instance (lobbyMgr) itself. So how do I ultimately do the following, but without a syntax err:
// Syntax Err
public override void lobbyMgr.OnMatchList(bool success, string extendedInfo, List<MatchInfoSnapshot> matchList){}
- 12/16: When I created a match and request the access token, it’s the SAME token on both hosts – what does this mean? I thought the token is based off the match, not just me? Does this mean 2 players created an identical match? Something is not sync’ing here.
- 12/16: The extremely outdated Network Lobby demo matchmaking isn’t working for me, after following the instructions: The list is always empty! Can anyone else test this?
- 12/16: Notable find - when I create a match on both PC “A” and PC “B”, both the match.networkId are identical. Is this normal?
- 12/16: When a game is CREATED, all the matchInfo is there like it should be. When I attempt to LIST the matches, I’m always returned an empty (not null, but count == 0) list, even when a game is hosted on another PC.
- 12/16: Our senior dev also took a look at this and suspects the issues start at StartMatchMaker(), that does’t seem to be sync’d with where it’s supposed to. Not 100% sure, just a suspicion.
- 12/16: The NetworkManager class singleton (NetworkManager.singleton) is supposed to trigger as soon as anything on the network is happening. However, when I call the NetworkManager.singleton.GetInstanceID, it’s null. Perhaps this is where the out-of-sync action occurs. Not sure, but worth noting.
- 12/16: Both lobbyMgr.matchMaker.instanceId && NetworkManager.singleton.instanceId MATCH! Maybe it’s something else…