- Home /
[Multiplayer] OnMatchList() isn't firing after ListMatches() when using NetworkLobbyManager
TL;DR summary:
I have [SerializeField] NetworkLobbyManager lobbyMgr and dropped in the new NetworkLobbyManager component and attached a Mono lobbyScript.cs
Inside lobbyScript, I lobbyMgr.StartMatchMaker()
I then make a match, lobbyMgr.MatchMaker.CreateMatch(...lobbyMgr.OnMatchCreate). Notice the callback for the serialized lobbyMgr instance.
I need to override lobbyMgr.OnmatchCreate >> How?
TL;DR trial and error:
I tried changing the script to inherit from NetworkLobbyManager instead of Mono - however, I then had 2 separate NetworkLobbyManager instances. I could generally override void OnMatchCreate, but if I do this, then: OnMatchCreate() callback never fires. lobbyMgr.ListMatches() returns nothing. It's out of sync. Different instances?
I tried to use my own callback: .CreateMatch(...OnMatchCreateCustom), and the callback DID fire, however, similar to #1, it became out of sync. Apparently when lobbyMgr gets a callback, it probably also saves the match in the background. I need to override the lobbyMgr instance -- not use my own callback. OnMatchCreate() DOES fire, but.. lobbyMgr.ListMatches() returns nothing. It's out of sync. Different instances?
Details:
I call the serialized LobbyNetworkManager (lobbyMgr) via
lobbyMgr.matchMaker.ListMatches(params, etc, nextParamIsCallback, lobbyMgr.OnmatchList)
Then.. the Lobby script derived from MonoBehaviour:
public override void OnMatchCreate(bool success, string extendedInfo, MatchInfo matchInfo)
{
Debug.Log("@ OnMatchCreate - WHICH NEVER FIRES");
}
That is when I dove into the matchmaking class and realized that .. you can't override on MonoBehaviour, but inheriting from NetworkLobbyManager causes conflicts with ... well, your serialized lobbyMgr!
So how do I access the serialized lobbyMgr's matchmaking callbacks?
I can't do anything like override void lobbyMgr.OnWhatever()
, so how do I do it in 5.5b+?
11/19 update: I discovered 5.5b API doc conflicts:
I discovered that this 5.5b doc says that On$$anonymous$$atchList returns is:
On$$anonymous$$atchList(List$$anonymous$$atchResponse matchList)
However, this 5.5b doc shows completely different format and parameters:
On$$anonymous$$atchList(bool success, string extendedInfo, List<$$anonymous$$atchInfoSnapshot> matchList)
EDIT 2: The old code that allegedly worked was this (which no longer works):
public override void On$$anonymous$$atchCreate(Create$$anonymous$$atchResponse create$$anonymous$$atchResponse)
{
base.On$$anonymous$$atchCreate(create$$anonymous$$atchResponse);
Debug.Log("@ On$$anonymous$$atchCreate);
}
EDIT 3: The callback with the longer params is the correct one: https://docs.unity3d.com/550/Documentation/$$anonymous$$anual/UpgradeGuide54Networking.html
11/25/2016 Update:
Although the syntax is accepted with my own callback ins$$anonymous$$d of lobby$$anonymous$$gr.On$$anonymous$$atchList, and is fired, it apparently makes my serialized lobby$$anonymous$$gr component out of sync! Likely because of different instances?
If I use this way,
PC-A starts matchmaking, looks for an open game in list, nothing in list, so creates a match.
PC-B start matchmaking, looks for an open game in list, nothing in list -- this means that although the game exists somewhere, not in the same instance as my serialized lobby$$anonymous$$gr component.
This means I still have issues.
I need to find a way to access the serialized lobby$$anonymous$$gr.OnWhatever() callback events INSIDE lobby$$anonymous$$gr.
I tried changing my lobbyScript [attached to my serialized lobby$$anonymous$$gr component to inherit from NetworkLobby$$anonymous$$anager - originally from $$anonymous$$ono. I could then properly void override On$$anonymous$$atchList(), but it was never fired because it's a different instance -- I then technically have two NetworkLobby$$anonymous$$anager's -- this isn't the solution. I need to specifically access lobby$$anonymous$$gr.On$$anonymous$$atchList() somehow. How do I do it?
I can't simply do override void lobby$$anonymous$$gr.On$$anonymous$$atchList
because it's a syntax error - but that is what I am trying to achieve, ultimately, if someone has the correct syntax to do so
11/29: Still awaiting an answer -- trial and error can only go so far :/