unity-game-engineunity-networkingmatchmaking

[Unity 5]matchmaking : matches not visible


I need your help please because I have an issue about matchmaking. I try to make a Pong playable online. When i use NetworkHUD, and I use Matchmaker, I can create a match, and the other app (on the same computer for now) detach it and can join it. But, when I don't use it, but I use matchmaker manually, I can create a match, I have a success response, I can find this match in the same app, but, in my second app, I can't find match created by the first app.

Can you help me?

Here are two functions in which I create match :

 public void matchmaking()
     {
         nm.StartMatchMaker();
         networkMatch.ListMatches(0, 20, "", OnMatchList);
         Debug.LogError ("NBR MATCH " +matchList.Count);
         if (matchList.Count == 0)
         {
             CreateMatchRequest match = new CreateMatchRequest();
             match.name = "OrionPongRoom";
             match.size = 2;
             match.advertise = true;
             match.password = "";
             networkMatch.CreateMatch(match, OnMatchCreate);
         }
         else
             Debug.Log ("******matches found"+matchList.Count);
     }
    void OnMatchCreate(CreateMatchResponse matchResponse)
 {
     if (matchResponse.success)
     {
         Debug.LogError("Create match succeeded");
         matchCreated = true;
         MatchInfo matchInfo = new MatchInfo(matchResponse);
         Utility.SetAccessTokenForNetwork(matchResponse.networkId, new NetworkAccessToken(matchResponse.accessTokenString));
         nm.StartHost(matchInfo);
         NetworkServer.Listen(9000);
         //NetworkServer.Listen(new MatchInfo(matchResponse), 9000);
     }
     else
     {
         Debug.LogError ("Create match failed");
     }
 }

Solution

  • You need to write

         if (matchList.Count == 0)
         {
             CreateMatchRequest match = new CreateMatchRequest();
             match.name = "OrionPongRoom";
             match.size = 2;
             match.advertise = true;
             match.password = "";
             networkMatch.CreateMatch(match, OnMatchCreate);
         }
         else
             Debug.Log ("******matches found"+matchList.Count);
    

    in OnMatchList method.

    void OnMatchList(ListMatchResponse matchList)
    {
      if (matchList.Count == 0)
             {
                 CreateMatchRequest match = new CreateMatchRequest();
                 match.name = "OrionPongRoom";
                 match.size = 2;
                 match.advertise = true;
                 match.password = "";
                 networkMatch.CreateMatch(match, OnMatchCreate);
             }
             else
                 Debug.Log ("******matches found"+matchList.Count);
    }
    

    Because of Network Delays etc, matchmaking server can not send response synchronous.