ping reporting

This commit is contained in:
2026-06-02 14:47:32 +05:30
parent d62bf9e06b
commit 2651068b50
12 changed files with 2756 additions and 62 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+97 -24
View File
@@ -1,25 +1,98 @@
Logger initiated at 5/29/2026 9:58:40 AM Logger initiated at 6/2/2026 2:22:58 PM
[5/29/2026 9:58:40 AM] Cupid settings updated [6/2/2026 2:22:58 PM] Cupid settings updated
[5/29/2026 9:58:40 AM] Cupid settings updated [6/2/2026 2:22:58 PM] Cupid settings updated
[5/29/2026 9:58:41 AM] Starting matchmake as warlock [6/2/2026 2:22:59 PM] Starting matchmake as warlock2
[5/29/2026 9:58:44 AM] Got into a room [6/2/2026 2:23:02 PM] Still waiting: {"ok":true,"entry_fee":21,"rc_prize":34,"for_red":{"Players":[{"Name":"warlock","LastSeen":1780390382670,"UserId":2,"l10_wins":3,"l10_losses":2}],"GameName":"soccar","Port":26544,"InitTime":1780390382670,"entry_fee":21,"match_id":148,"rc_prize":34,"your_team":"red"},"for_blue":null}
[5/29/2026 9:58:44 AM] {"ok":true,"entry_fee":21,"rc_prize":34,"for_red":{"Players":[{"Name":"warlock2","LastSeen":1780028923470,"UserId":3,"l10_wins":5,"l10_losses":3},{"Name":"warlock","LastSeen":1780028923874,"UserId":2,"l10_wins":3,"l10_losses":6}],"GameName":"soccar","Port":26438,"InitTime":1780028923470,"entry_fee":21,"match_id":128,"instance_started":true,"rc_prize":34,"your_team":"red"},"for_blue":{"Players":[{"Name":"warlock2","LastSeen":1780028923470,"UserId":3,"l10_wins":5,"l10_losses":3},{"Name":"warlock","LastSeen":1780028923874,"UserId":2,"l10_wins":3,"l10_losses":6}],"GameName":"soccar","Port":26438,"InitTime":1780028923470,"entry_fee":21,"match_id":128,"instance_started":true,"rc_prize":34,"your_team":"blue"}} [6/2/2026 2:23:03 PM] Got into a room
[5/29/2026 9:58:44 AM] Configured dedicated match reporting for match id 128 with secret 38516e39d3406225b7c3015a66e5d25c54e9b2024c0755212122bdcea3e3a328 and internal api base https://kickkingsapi.playpoolstudios.com [6/2/2026 2:23:03 PM] {"ok":true,"entry_fee":21,"rc_prize":34,"for_red":{"Players":[{"Name":"warlock","LastSeen":1780390382670,"UserId":2,"l10_wins":3,"l10_losses":2},{"Name":"warlock2","LastSeen":1780390383139,"UserId":3,"l10_wins":3,"l10_losses":3}],"GameName":"soccar","Port":26544,"InitTime":1780390382670,"entry_fee":21,"match_id":148,"instance_started":true,"rc_prize":34,"your_team":"red"},"for_blue":{"Players":[{"Name":"warlock","LastSeen":1780390382670,"UserId":2,"l10_wins":3,"l10_losses":2},{"Name":"warlock2","LastSeen":1780390383139,"UserId":3,"l10_wins":3,"l10_losses":3}],"GameName":"soccar","Port":26544,"InitTime":1780390382670,"entry_fee":21,"match_id":148,"instance_started":true,"rc_prize":34,"your_team":"blue"}}
[5/29/2026 9:58:44 AM] Setting cupid to load game scene [6/2/2026 2:23:03 PM] Configured dedicated match reporting for match id 148 with secret 38516e39d3406225b7c3015a66e5d25c54e9b2024c0755212122bdcea3e3a328 and internal api base https://kickkingsapi.playpoolstudios.com
[5/29/2026 9:58:44 AM] Loading game scene [6/2/2026 2:23:03 PM] Setting cupid to load game scene
[5/29/2026 9:58:48 AM] Starting client at $kickkingsapi.playpoolstudios.com:26438 [6/2/2026 2:23:03 PM] Loading game scene
[5/29/2026 9:58:48 AM] Client connected [6/2/2026 2:23:04 PM] Got into a room
[5/29/2026 9:58:55 AM] Selected team changed from Red to Blue [6/2/2026 2:23:04 PM] {"ok":true,"entry_fee":21,"rc_prize":34,"for_red":{"Players":[{"Name":"warlock","LastSeen":1780390384353,"UserId":2,"l10_wins":3,"l10_losses":2},{"Name":"warlock2","LastSeen":1780390383139,"UserId":3,"l10_wins":3,"l10_losses":3}],"GameName":"soccar","Port":26544,"InitTime":1780390382670,"entry_fee":21,"match_id":148,"instance_started":true,"rc_prize":34,"your_team":"red"},"for_blue":{"Players":[{"Name":"warlock","LastSeen":1780390384353,"UserId":2,"l10_wins":3,"l10_losses":2},{"Name":"warlock2","LastSeen":1780390383139,"UserId":3,"l10_wins":3,"l10_losses":3}],"GameName":"soccar","Port":26544,"InitTime":1780390382670,"entry_fee":21,"match_id":148,"instance_started":true,"rc_prize":34,"your_team":"blue"}}
[5/29/2026 9:58:58 AM] Score changed from 0 to 1 [6/2/2026 2:23:04 PM] Configured dedicated match reporting for match id 148 with secret 38516e39d3406225b7c3015a66e5d25c54e9b2024c0755212122bdcea3e3a328 and internal api base https://kickkingsapi.playpoolstudios.com
[5/29/2026 9:59:01 AM] Selected team changed from Blue to Red [6/2/2026 2:23:04 PM] Setting cupid to load game scene
[5/29/2026 9:59:07 AM] Selected team changed from Red to Blue [6/2/2026 2:23:04 PM] Loading game scene
[5/29/2026 9:59:09 AM] Score changed from 1 to 2 [6/2/2026 2:23:08 PM] Starting client at $kickkingsapi.playpoolstudios.com:26544
[5/29/2026 9:59:12 AM] Selected team changed from Blue to Red [6/2/2026 2:23:08 PM] Client connected
[5/29/2026 9:59:15 AM] Selected team changed from Red to Blue [6/2/2026 2:23:09 PM] Starting client at $kickkingsapi.playpoolstudios.com:26544
[5/29/2026 9:59:17 AM] Score changed from 2 to 3 [6/2/2026 2:23:09 PM] Client connected
[5/29/2026 9:59:29 AM] Configured dedicated match reporting for match id 129 with secret 38516e39d3406225b7c3015a66e5d25c54e9b2024c0755212122bdcea3e3a328 and internal api base https://kickkingsapi.playpoolstudios.com [6/2/2026 2:23:17 PM] Selected team changed from Red to Blue
[5/29/2026 9:59:29 AM] Client disconnected [6/2/2026 2:23:17 PM] Selected team changed from Red to Blue
[5/29/2026 9:59:33 AM] Starting client at $kickkingsapi.playpoolstudios.com:26658 [6/2/2026 2:23:32 PM] Selected team changed from Blue to Red
[5/29/2026 9:59:34 AM] Client connected [6/2/2026 2:23:32 PM] Selected team changed from Blue to Red
[5/29/2026 9:59:54 AM] Client disconnected [6/2/2026 2:23:47 PM] Selected team changed from Red to Blue
[6/2/2026 2:23:47 PM] Selected team changed from Red to Blue
[6/2/2026 2:24:02 PM] Selected team changed from Blue to Red
[6/2/2026 2:24:02 PM] Selected team changed from Blue to Red
[6/2/2026 2:24:17 PM] Selected team changed from Red to Blue
[6/2/2026 2:24:17 PM] Selected team changed from Red to Blue
[6/2/2026 2:24:32 PM] Selected team changed from Blue to Red
[6/2/2026 2:24:33 PM] Selected team changed from Blue to Red
[6/2/2026 2:24:48 PM] Selected team changed from Red to Blue
[6/2/2026 2:24:48 PM] Selected team changed from Red to Blue
[6/2/2026 2:25:03 PM] Selected team changed from Blue to Red
[6/2/2026 2:25:03 PM] Selected team changed from Blue to Red
[6/2/2026 2:25:18 PM] Selected team changed from Red to Blue
[6/2/2026 2:25:18 PM] Selected team changed from Red to Blue
[6/2/2026 2:25:33 PM] Selected team changed from Blue to Red
[6/2/2026 2:25:33 PM] Selected team changed from Blue to Red
[6/2/2026 2:25:48 PM] Selected team changed from Red to Blue
[6/2/2026 2:25:48 PM] Selected team changed from Red to Blue
[6/2/2026 2:26:03 PM] Selected team changed from Blue to Red
[6/2/2026 2:26:03 PM] Selected team changed from Blue to Red
[6/2/2026 2:26:18 PM] Selected team changed from Red to Blue
[6/2/2026 2:26:19 PM] Selected team changed from Red to Blue
[6/2/2026 2:26:34 PM] Selected team changed from Blue to Red
[6/2/2026 2:26:34 PM] Selected team changed from Blue to Red
[6/2/2026 2:26:49 PM] Selected team changed from Red to Blue
[6/2/2026 2:26:49 PM] Selected team changed from Red to Blue
[6/2/2026 2:27:04 PM] Selected team changed from Blue to Red
[6/2/2026 2:27:04 PM] Selected team changed from Blue to Red
[6/2/2026 2:27:19 PM] Selected team changed from Red to Blue
[6/2/2026 2:27:19 PM] Selected team changed from Red to Blue
[6/2/2026 2:27:34 PM] Selected team changed from Blue to Red
[6/2/2026 2:27:34 PM] Selected team changed from Blue to Red
[6/2/2026 2:27:49 PM] Selected team changed from Red to Blue
[6/2/2026 2:27:49 PM] Selected team changed from Red to Blue
[6/2/2026 2:28:05 PM] Selected team changed from Blue to Red
[6/2/2026 2:28:05 PM] Selected team changed from Blue to Red
[6/2/2026 2:28:20 PM] Selected team changed from Red to Blue
[6/2/2026 2:28:20 PM] Selected team changed from Red to Blue
[6/2/2026 2:28:35 PM] Selected team changed from Blue to Red
[6/2/2026 2:28:35 PM] Selected team changed from Blue to Red
[6/2/2026 2:28:50 PM] Selected team changed from Red to Blue
[6/2/2026 2:28:50 PM] Selected team changed from Red to Blue
[6/2/2026 2:29:05 PM] Selected team changed from Blue to Red
[6/2/2026 2:29:05 PM] Selected team changed from Blue to Red
[6/2/2026 2:29:20 PM] Selected team changed from Red to Blue
[6/2/2026 2:29:20 PM] Selected team changed from Red to Blue
[6/2/2026 2:29:35 PM] Selected team changed from Blue to Red
[6/2/2026 2:29:35 PM] Selected team changed from Blue to Red
[6/2/2026 2:29:51 PM] Selected team changed from Red to Blue
[6/2/2026 2:29:51 PM] Selected team changed from Red to Blue
[6/2/2026 2:30:06 PM] Selected team changed from Blue to Red
[6/2/2026 2:30:06 PM] Selected team changed from Blue to Red
[6/2/2026 2:30:21 PM] Selected team changed from Red to Blue
[6/2/2026 2:30:21 PM] Selected team changed from Red to Blue
[6/2/2026 2:30:36 PM] Selected team changed from Blue to Red
[6/2/2026 2:30:36 PM] Selected team changed from Blue to Red
[6/2/2026 2:30:51 PM] Selected team changed from Red to Blue
[6/2/2026 2:30:51 PM] Selected team changed from Red to Blue
[6/2/2026 2:31:06 PM] Selected team changed from Blue to Red
[6/2/2026 2:31:06 PM] Selected team changed from Blue to Red
[6/2/2026 2:31:21 PM] Selected team changed from Red to Blue
[6/2/2026 2:31:22 PM] Selected team changed from Red to Blue
[6/2/2026 2:31:37 PM] Selected team changed from Blue to Red
[6/2/2026 2:31:37 PM] Selected team changed from Blue to Red
[6/2/2026 2:31:52 PM] Selected team changed from Red to Blue
[6/2/2026 2:31:52 PM] Selected team changed from Red to Blue
[6/2/2026 2:32:07 PM] Selected team changed from Blue to Red
[6/2/2026 2:32:07 PM] Selected team changed from Blue to Red
[6/2/2026 2:32:22 PM] Selected team changed from Red to Blue
[6/2/2026 2:32:22 PM] Selected team changed from Red to Blue
[6/2/2026 2:32:37 PM] Selected team changed from Blue to Red
[6/2/2026 2:32:37 PM] Selected team changed from Blue to Red
[6/2/2026 2:32:40 PM] Client disconnected
[6/2/2026 2:32:44 PM] Client disconnected
+2 -2
View File
@@ -4339,7 +4339,7 @@ MonoBehaviour:
m_OnCullStateChanged: m_OnCullStateChanged:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls: []
m_Sprite: {fileID: 21300000, guid: 7b4541dccf68a5a479d7bc41c620fae2, type: 3} m_Sprite: {fileID: 21300000, guid: 0141b420cef50bf4781442dc4dda275a, type: 3}
m_Type: 0 m_Type: 0
m_PreserveAspect: 0 m_PreserveAspect: 0
m_FillCenter: 1 m_FillCenter: 1
@@ -4554,7 +4554,7 @@ MonoBehaviour:
preview: 0 preview: 0
isPlaying: 1 isPlaying: 1
loop: 1 loop: 1
currentFrame: 89 currentFrame: 56
--- !u!1 &239916595 --- !u!1 &239916595
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
+60
View File
@@ -614,6 +614,12 @@ public class LoginManager : MonoBehaviour
StartCoroutine(PurchaseRcCoroutine(packId, onComplete)); StartCoroutine(PurchaseRcCoroutine(packId, onComplete));
} }
/// <summary>POST /auth/ping-report with <c>{"match_id":123,"ping":42}</c>. Callback (success, errorOrNull, reportOrNull).</summary>
public void ReportPing(int matchId, int ping, Action<bool, string, PingReportData> onComplete)
{
StartCoroutine(ReportPingCoroutine(matchId, ping, onComplete));
}
IEnumerator PurchaseRcCoroutine(string packId, Action<bool, string> onComplete) IEnumerator PurchaseRcCoroutine(string packId, Action<bool, string> onComplete)
{ {
if (string.IsNullOrEmpty(AuthToken)) if (string.IsNullOrEmpty(AuthToken))
@@ -687,6 +693,59 @@ public class LoginManager : MonoBehaviour
} }
} }
IEnumerator ReportPingCoroutine(int matchId, int ping, Action<bool, string, PingReportData> onComplete)
{
if (string.IsNullOrEmpty(AuthToken))
{
onComplete?.Invoke(false, "Not signed in", null);
yield break;
}
string json = "{\"match_id\":" + matchId + ",\"ping\":" + ping + "}";
string url = AuthBaseUrl + "/auth/ping-report";
using (var request = new UnityWebRequest(url, UnityWebRequest.kHttpVerbPOST))
{
byte[] bodyRaw = Encoding.UTF8.GetBytes(json);
request.uploadHandler = new UploadHandlerRaw(bodyRaw);
request.downloadHandler = new DownloadHandlerBuffer();
request.SetRequestHeader("Content-Type", "application/json");
request.SetRequestHeader("Authorization", "Bearer " + AuthToken);
yield return request.SendWebRequest();
string text = request.downloadHandler != null ? request.downloadHandler.text : "";
if (request.result != UnityWebRequest.Result.Success &&
request.result != UnityWebRequest.Result.ProtocolError)
{
onComplete?.Invoke(false, string.IsNullOrEmpty(request.error) ? "Network error" : request.error, null);
yield break;
}
if (request.responseCode < 200 || request.responseCode >= 300)
{
onComplete?.Invoke(false, string.IsNullOrEmpty(text) ? "Request failed (" + request.responseCode + ")" : text, null);
yield break;
}
if (string.IsNullOrEmpty(text))
{
onComplete?.Invoke(false, "Empty response from server", null);
yield break;
}
PingReportApiResponse resp = JsonUtility.FromJson<PingReportApiResponse>(text);
if (resp != null && resp.ok && resp.report != null)
onComplete?.Invoke(true, null, resp.report);
else
{
string err = resp != null && !string.IsNullOrEmpty(resp.error) ? resp.error : "Ping report failed";
onComplete?.Invoke(false, err, null);
}
}
}
IEnumerator FetchUserDataCoroutine(Action<bool, string, UserData> onComplete, bool applyToStatic) IEnumerator FetchUserDataCoroutine(Action<bool, string, UserData> onComplete, bool applyToStatic)
{ {
if (string.IsNullOrEmpty(AuthToken)) if (string.IsNullOrEmpty(AuthToken))
@@ -739,4 +798,5 @@ public class LoginManager : MonoBehaviour
} }
} }
} }
} }
+33
View File
@@ -8,6 +8,7 @@ using UnityEngine.InputSystem;
#endif #endif
public class NetPlayer : NetworkBehaviour public class NetPlayer : NetworkBehaviour
{ {
const float PingReportIntervalSeconds = 30f;
[SyncVar] [SyncVar]
public int userId; public int userId;
@@ -99,6 +100,7 @@ public class NetPlayer : NetworkBehaviour
bool isDragging; bool isDragging;
Vector2 lastDragScreenPosition; Vector2 lastDragScreenPosition;
bool serverDragActive; bool serverDragActive;
Coroutine pingReportCoroutine;
#region EMOTES #region EMOTES
public void SendTextEmote(string txtName){ public void SendTextEmote(string txtName){
@@ -158,10 +160,16 @@ public class NetPlayer : NetworkBehaviour
if(isLocalPlayer){ if(isLocalPlayer){
localPlayer = this; localPlayer = this;
SetupInputPanel(); SetupInputPanel();
pingReportCoroutine = StartCoroutine(CoReportPingPeriodically());
} }
} }
void OnDestroy(){ void OnDestroy(){
if (pingReportCoroutine != null)
{
StopCoroutine(pingReportCoroutine);
pingReportCoroutine = null;
}
if(localPlayer == this){ if(localPlayer == this){
localPlayer = null; localPlayer = null;
} }
@@ -555,4 +563,29 @@ public class NetPlayer : NetworkBehaviour
GameOverCanvas.instance.OnRematchCancelled(); GameOverCanvas.instance.OnRematchCancelled();
} }
IEnumerator CoReportPingPeriodically()
{
var wait = new WaitForSecondsRealtime(PingReportIntervalSeconds);
while (isLocalPlayer)
{
yield return wait;
if (!NetworkClient.active || !NetworkClient.isConnected)
continue;
if (LoginManager.instance == null || string.IsNullOrEmpty(LoginManager.AuthToken))
continue;
int matchId = GameManager.DedicatedMatchId;
if (matchId <= 0)
continue;
int pingMs = Mathf.Max(0, Mathf.RoundToInt((float)(NetworkTime.rtt * 1000.0)));
LoginManager.instance.ReportPing(matchId, pingMs, (ok, err, report) =>
{
if (!ok && !string.IsNullOrEmpty(err))
Logger.Log("Ping report failed: " + err);
});
}
}
} }
@@ -0,0 +1,10 @@
using System;
using UnityEngine;
[Serializable]
public class PingReportApiResponse
{
public bool ok;
public string error;
public PingReportData report;
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 76e4e69960816204d8a01d0e534e0bf4
@@ -0,0 +1,13 @@
using System;
using UnityEngine;
[Serializable]
public class PingReportData
{
public int id;
public int user_id;
public int match_id;
public int ping;
public string ip_address;
public string created_at;
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: b3f6089d3b18cb34482d7de0cd8bca51
File diff suppressed because one or more lines are too long