question

Martin Rivers avatar image
Martin Rivers asked

,Advice on how to get preferred player Region for Matchmaking in Unity

,

Hi,

I've been struggling find a specific example on how to get the latency for the QoS Servers available for the title using Unity.

I have no experienced in networking and using UDP sockets, but I've attempted to follow the guidance in https://docs.microsoft.com/en-us/gaming/playfab/features/multiplayer/servers/using-qos-beacons-to-measure-player-latency-to-azure with no success.

I did managed to integrate the C# QoS example from the link into a Unity project but it ended up throwing an NotSupportedException when attempting to DoPost.

Originally I was hoping there was an out of the box API in Playfab that would do this rather than having everyone who wants to use Matchmaking have to implement their own latency check.

I've searched and not found much detail on simple implementation (it doesn't help that I don't really know what I should be looking for) so thought I'd ask on here if anyone could point me at a resource/tutorial I could follow to help me implement something so I can get the latency from the QoS servers for my title.

10 |1200

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

1 Answer

·
Seth Du avatar image
Seth Du answered

Currently, there is no out-of-box solution in Unity SDK. We have the C# sample on https://github.com/PlayFab/gsdkSamples/tree/master/WindowsRunnerCSharp/WindowsRunnerCSharpClient and PlayFab have created PlayFabQosApi.cpp to help developers measure QoS. I am not sure how you get not supported error, can you provide any code snippet? It is correct to import C# sample to Unity, but there should be modification on the codes to make it work. Please feel free to send a thread on Feature Request forum.

2 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.

Martin Rivers avatar image Martin Rivers commented ·

Thanks for the reply.

What you have provided is what I have already integrated into a project which is available through the link I posted.

When digging into the NotSupportedException I found that the project didn't seem to like this line

#if (NETSTANDARD && !NETSTANDARD1_1) || NETFRAMEWORK || NETCOREAPP

and so would jump straight to the #else where the exception sits.

I tested removing this line and it always seem to give me some ridiculous latency.

So I did some more searching and came across this https://docs.microsoft.com/en-us/dotnet/api/system.net.sockets.udpclient?view=netcore-3.1 which I used and added a stopwatch to calculate the latency.

Strangely, I left the PlayFabQosApi code running after I added my own UdpClient and the PlayFabQosApi is now returning real latencies which are pretty similar to what I'm getting from my own latency check.

Personally, I think if someone else comes across this problem I would recommend building their own UdpClient as this took me much less time than adding the PlayFabQosApi and resolving all the dependency errors, though I'm sure the PlayFabQosApi is likely much more robust.

Certainly an interesting learning experience.

1 Like 1 ·
Seth Du avatar image Seth Du ♦ Martin Rivers commented ·

Thanks for the sharing. In fact, we were also using a self-created UDP Client for testing QoS, but since it is crafted roughly, we don't want to share it as an official reference. Your answer will be valuable for the developers in the community.

0 Likes 0 ·

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.