Sooooo…
I have been fighting with this mathmaker for about two weeks now, and this is what i got so far
Creating a match works. Like this :
public void CreateMatch ()
{
CreateMatchRequest create = new CreateMatchRequest();
create.name = "TestMatch" ;
create.size = 2 ;
create.advertise = true ;
create.password = "" ;
networkMatch.CreateMatch(create, MatchCreated);
}
public void MatchCreated (CreateMatchResponse matchResponse)
{
if (matchResponse.success)
{
matchCreated = true ;
matchInfo = new MatchInfo(matchResponse);
Utility.SetAccessTokenForNetwork(matchResponse.networkId, new NetworkAccessToken(matchResponse.accessTokenString));
StartHost(matchInfo) ;
}
}
And NOT as described in the docs. you must add (matchInfo) after StartHost. otherwise you simply start hosting on your local network…
Same thing for the client : Joining a match works the same info. You request the matchInfo that you wish to join, join it, and if success you do StartClient(matchInfo), otherwise, you only try to connect your client to a localHost.
Now… since that took me some days… i now want to handle when the user Cancel a match he made…
The NetworkMatch.DestroyMatch(…) as described in the docs DOES NOT work.
Example :
networkMatch.DestroyMatch(matchInfo.networkId,CancelMatch) ;
will give you :
System.FormatException: FAILURE Returned from server: DestroyMatch Failed unity_GetAuthInfoFromSourceId appId=41551
Even you are 100 % you are trying to cancel a match that you created, and that you are passing the right networkID.
And last Thing :
If you create a match and StartHost()… Then… you StopHost().
You have to wait a few minutes for your match to be gone from the matchList. Otherwise, since you probably have coded in a way that you will join the first match that is opened to you and has enough space, you will try to rejoin the match that has now …no Host…
unity will give you
"
ArgumentException: An element with the same key already exists in the dictionary.
System.Collections.Generic.Dictionary`2[UnityEngine.Networking.Types.NetworkID,UnityEngine.Networking.Types.NetworkAccessToken].Add (NetworkID key, UnityEngine.Networking.Types.NetworkAccessToken value) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:404) "
BUT : you will join the match, and there is no way to catch that error prior.
OnClientError and others similar functions will not trigger.
Conclusion : that matchmaker is simply not workable in its current state. Nowhere near prod ready for any game. Have fun with it may be, but right now, it simply does not work.
Unless i missed something, i am giving up on that matchmaker for now. i will finish my game with everything i want in, and will keep the matchmaker for the last part. Unfortunatly, there is no way to use another matchmaker service, with Unet, other than Unity’s. So that might involves re-coding the network logic of my game… which is a pain…
So, if anyone has something to add to it, point me to as to what i am doing wrong, or what should i go with… that would be appreciated, if not , i hope some people starting with the network and unet specifically will find those infos helpful.