Search Unity

Multiplayer lobby manager problem

Discussion in 'Multiplayer' started by TwinForce, Jul 12, 2016.

  1. TwinForce

    TwinForce

    Joined:
    Feb 21, 2016
    Posts:
    5
    Our team is working on a multiplayer game set up using Unity multiplayer services and the high level API. It was of our interest to use the Lobby Manager to create a common meeting point for players to join before starting a game together. The problem is that the games that are already being played are retrieved by searches, so new players looking for games will find this game and try to join. Is there any way to filter out those games that should no longer be announced as thay have already sarted and no new players can join?

    Our developers, as a temporal solution, were thinking about modifying a custom parameter and filtering out ongoing games on the client side, but they realized the API seems not to offer any way to modify a game already being announced (created by matchmaker). We would like to know if there is any way to accomplish that, but the ideal scenario would be to filter out those games server side (by Unity servers).
     
  2. ProfTroy

    ProfTroy

    Joined:
    Mar 18, 2013
    Posts:
    26
    If you find a solution, please share. I'm trying to find a better solution as well.
     
  3. Driiades

    Driiades

    Joined:
    Oct 27, 2015
    Posts:
    151
    Same here....
     
  4. Driiades

    Driiades

    Joined:
    Oct 27, 2015
    Posts:
    151
    I have a work around on this :

    On a NetworkManager :


    public class MatchMessage : MessageBase
    {
    public bool locked = false;
    }


    public override void OnServerConnect(NetworkConnection conn)
    {
    base.OnServerConnect(conn);

    MatchMessage msg = new MatchMessage();
    msg.locked = matchIsLocked;
    NetworkServer.SendToClient(conn.connectionId,connectionMessage, msg);

    if (matchIsLocked)
    NetworkServer.SendToClient(conn.connectionId, matchLockMessage, msg);
    }


    And On a MatchmakingManager :



    void Start()
    {
    Unfair_NetworkManager.Instance.OnClientConnected += (conn) => { conn.RegisterHandler(Unfair_NetworkManager.matchLockMessage, OnMatchLockMessage); };
    }


    void OnMatchLockMessage(NetworkMessage netMsg)
    {
    var msg = netMsg.ReadMessage<Unfair_NetworkManager.MatchMessage>();
    Debug.Log("arrivé là " + msg.locked);


    if (msg.locked)
    {
    Debug.Log("coucou je suis ici et je suis heureux");
    SceneManager.LoadScene(lastScene);
    }
    }




    This will disconnect your player on a locked game. This will avoid to break games with a player who not have to be here. But it's buggy because of the LoadScene (i was obligate to return to this scene, however my player went on the game scene...)


    If someone have a really good solution for this... i'm here ^^.
     
  5. TwinForce

    TwinForce

    Joined:
    Feb 21, 2016
    Posts:
    5
    Hi guys, sorry for the delay. The Unity Multiplayer support team gave us some more insight on this problem. Here is our correspondence about the matter:

    ANSWER MULTIPLAYER SUPPORT 1:

    Thank you for the email.

    In regards to your query, I spoke to the Multiplayer Team in regards to this query, they came back with the following, yes you can delist a match, but it requires using JSON that isn't in 5.3.

    The description is here: https://mm.unet.unity3d.com/json/metadata?op=SetMatchAttributesRequest

    Only the host of the match can do that, but if that’s sent to the matchmaker as described with islisted=false then the list will no longer show up in listmatch results.

    Hope this helps!

    ANSWER TWINFORCE 1:


    Thanks for the response, it was very helpful.

    Our developers are currently trying to implement the solution building a JSON by hand (a handmade string) and then sending the request to Unity cloud servers using the experimental UnityWebRequest:

    UnityWebRequest request = UnityWebRequest.Post("https://mm.unet.unity3d.com/json/reply/SetMatchAttributesRequest" (https://mm.unet.unity3d.com/json/reply/SetMatchAttributesRequest) , jsonData);

    The request returns with an error, and we assume it is happening because of the data inside JSON is not configured properly:

    {"success":false,"extendedInfo":"Failed because of invalid projectid setup. Please verify project setup at https://multiplayer.unity3d.com."}

    They are trying to realize how to retrieve all the information the request needs (application identifiers, etc), but team is having difficulties retrieving some fields. From the request template shown at the link you provided:

    {"networkId":"18446744073709551615","isListed":false,"version":0,"sourceId":"18446744073709551615","projectId":"String","accessTokenString":"String","domain":0,"appId":"18446744073709551615"}

    We have 'appID' and 'projectID' from our project configuration page in unity multiplayer, 'version' is provided by the match creation request (CreateMatchRequest), 'networkId' and 'accessTokenString' can ve retrived by 'matchInfo' of the newly created match, but team does not know how to adquire the fields 'domain' and 'sourceID', as they seem like internal data used by cloud API and they are empty before and after the create match request has been completed.

    It would be great if you could help us shed some light in this matter.

    Regards

    ANSWER MULTIPLAYER SUPPORT 2:

    You need to projectId with the GUID ID for their project in the multiplayer in the multiplayer config site, also the domain should be 0, as for souceid, this can be accessed through UnityEngine.Networking.Utility.GetSourceID()

    As for the project configuration page, you only need to set appID can be set to AppID.Invalid. You will need to set AppID or ProjectID, and project id is the correct one that you found on the config portal already.

    Hope this helps