Context: My multiplayer game uses Unity Relay to guarantee that players will be able to connect, and it also uses Unity Lobby to publicly display matches and their data. I’m currently trying to include game latency in the Lobby data, so as to be able to order the matches by lowest latency.
Problem: I’ve not been able to find a simple way to get the latency of a match. My plan was to ping the selected relay server as a host to get the “Host to Relay” latency, and then do the same thing as a Client to get the “Client to Relay” latency, and finally add them up to get the estimated total latency the Client would have. However, I had problems trying to achieve this. Here’s what I’ve tried so far:
- Pinging The Relay IP: From the host side, I was able to get the Relay endpoint IP, so I tried using the simple Ping object to send a ping message. Unfortunately, the packet never arrived back, I assume the Relay servers drop normal ping messages
- Sending a PING message via the Unity Services Web APIs: I tried manually using the web API to send ping messages, I tried using the Relay message protocol or the Qos service for this… However, I kept getting “unauthorized” errors. I guess I’m doing something wrong here, It seems that I require a special key that it’s only accessible to the Organization owner for sending messages. Is that how it works? Or am I doing something wrong? My head hurts at this point… I also tried to get my credentials from my session in Unity Serives (since my game is done in Unity and I use the plugins and all), but I couldn’t access any tokens, I’ve only got my allocation secret key but I honestly don’t know how to use it, and I keep having trouble with the custom headers I need.
Question:
- Is there any easy solution for my problem that I’m not seeing? This is taking me alot of time, and I might be missing something very simple and obvious. If I am, please let me know.
- Should I keep going with the Web API route? Does anyone have any idea what I might be doing wrong here?
Thanks in advance…