question

Alexander Paul avatar image
Alexander Paul asked

Matchmaking Queue and Server Connect Sequence

Hi there,

I was wondering if you could give me some advice on how the sequence is on your end, because when I use matchmaking I have troubles getting the clients (mirror) started. Sometimes it works and sometimes the Mirror Start.Client function gets not listened to (I assume).

I am using Mirror and the PlayfabMultiplayerAgentApi and implemented your example on github.

In my case both players start matchmaking and get a match. Server then turns active in the GameManager. The Mirror NetworkServer starts listening as soon as the MPAgent does the OnServerActive Callback. (Like in your example).

When does the the playfab server turns active. After the getmatch result? I assume that there is a sequence / timing issue and I don't know where exactly.

Thanks

multiplayerMatchmaking
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Gosen Gao avatar image
Gosen Gao answered

GetMatch API will return the server detail, so it looks like a sign that the server has turn into active successfully. But actually, when the matchmaking system has gathered enough players, PlayFab will check for the standby servers and find a suitable server then turn it into active.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Alexander Paul avatar image Alexander Paul commented ·

@Gosen Gao Any idea on how I can let the players know that the MPAgent Server is active? So I can call the Mirror function called NetworkServer.StartClient() on the players when the Mirror NetworkServer is already listening and not before.

0 Likes 0 ·
Alexander Paul avatar image
Alexander Paul answered

Ah I see. So I already see the issue I think. I am calling Start.Client Mirror too early. I think this problem does not occure in the example since there is just a request server call and no matchmaking.

Alright thanks! So this means in my case with a queue of 2 the OnServerActive Callback gets called when the 2 players found a match and both join the server at the same time?

5 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Alexander Paul avatar image Alexander Paul commented ·

I called the Start.Client Mirror methode in the GetMatch result which is to early right?

0 Likes 0 ·
Seth Du avatar image Seth Du ♦ commented ·

Have you referred this tutorial? --Matchmaking quickstart - PlayFab | Microsoft Docs.

During the matchmaking, you may need to poll the state of ticket every few seconds and once the ticket state changes to "matched", you may call GetMatch to get server instance details. Once 'Matched', the server is active immediately due to the help of stand-by feature of PlayFab.

0 Likes 0 ·
Alexander Paul avatar image Alexander Paul Seth Du ♦ commented ·

Hi. I know, that is all working fine. Players are getting matched and are joining a server which will turn the server active. I am talking about my networking stuff with mirror.

On the playfab server my networking from mirror will call the NetworkServer.Listen() Method in your OnServerActive Callback.

@Gosen Gao explained to me that GetMatch result does not really turn the server active, it just gives me the details. And I was trying to call the Mirror StartClient function in the GetMatch result, which apparently is too early since my NetworkServer is not listening yet.

Any suggestions on how to let my players know that Playfab Server is active, so I can call the Mirror StartClient method when the server has turned active?

0 Likes 0 ·
Gosen Gao avatar image Gosen Gao Alexander Paul commented ·

Maybe I didn’t say it clearly. What I mean is before you can call GetMatch, the server is already turned into active by the Matchmaking system, so that the GetMatch API can return you the server detail. What you do that calling the Start.Client in the result of GetMatch is the right way. But in your scenario, I suggest you to add a delay in the GetMatch result before the Start.Client method is called. Also a retry method is feasible.

0 Likes 0 ·
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.