From e04bac7871518a758ba6dfc5e321d350e3c6e37a Mon Sep 17 00:00:00 2001 From: SlejmUr Date: Tue, 19 Sep 2023 16:41:03 +0200 Subject: [PATCH] fix lobby stuff, maybe fix challanges --- PayCheckServerLib/Responses/Challenge.cs | 17 ----------------- PayCheckServerLib/Servers/PC3Server.cs | 10 ++++++++-- PayCheckServerLib/WSController/LobbyControl.cs | 2 +- 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/PayCheckServerLib/Responses/Challenge.cs b/PayCheckServerLib/Responses/Challenge.cs index bfada87..c7d6d18 100644 --- a/PayCheckServerLib/Responses/Challenge.cs +++ b/PayCheckServerLib/Responses/Challenge.cs @@ -16,23 +16,6 @@ public static bool ChallengeEligibility(HttpRequest _, PC3Server.PC3Session sess return true; } - [HTTP("GET", "/challenge/v1/public/namespaces/pd3/users/me/records?limit=2147483647&offset=0")] - public static bool ChallengeRecordsAll(HttpRequest _, PC3Server.PC3Session session) - { - var auth = session.Headers["authorization"].Replace("Bearer ", ""); - var token = TokenHelper.ReadToken(auth); - ResponseCreator creator = new(); - var challenges = JsonConvert.DeserializeObject>(File.ReadAllText("Files/ChallengeRecords.json")) ?? throw new Exception("ChallengeRecords is null!"); - foreach (var item in challenges.Data) - { - item.UserId = token.UserId; - } - - creator.SetBody(JsonConvert.SerializeObject(challenges)); - session.SendResponse(creator.GetResponse()); - return true; - } - [HTTP("GET", "/challenge/v1/public/namespaces/pd3/users/me/records?limit={limit}&offset={offset}")] public static bool ChallengeRecordsSplit(HttpRequest _, PC3Server.PC3Session session) { diff --git a/PayCheckServerLib/Servers/PC3Server.cs b/PayCheckServerLib/Servers/PC3Server.cs index 20b3735..df9354c 100644 --- a/PayCheckServerLib/Servers/PC3Server.cs +++ b/PayCheckServerLib/Servers/PC3Server.cs @@ -1,5 +1,6 @@ using NetCoreServer; using PayCheckServerLib.Helpers; +using PayCheckServerLib.Responses; using PayCheckServerLib.WSController; using System.Net.Sockets; using System.Reflection; @@ -153,8 +154,13 @@ public override void OnWsDisconnecting() { "activity", "nil" }, { "platform", "nil" }, { "lastSeenAt", user.Status.lastSeenAt }, - }; - WSSServer().WSUserIds.ForEach(x => LobbyControl.SendToLobby(rsp, GetWSLobby(x))); + }; + foreach (var id in WSSServer().WSUserIds) + { + if (id == WSUserId) + continue; + LobbyControl.SendToLobby(rsp, GetWSLobby(id)); + } } WSS_Stuff.Remove(WS_ID + "_" + WS_ID.ToString().ToLower()); var serv = (PC3WSSServer)Server; diff --git a/PayCheckServerLib/WSController/LobbyControl.cs b/PayCheckServerLib/WSController/LobbyControl.cs index 541658b..e2328e5 100644 --- a/PayCheckServerLib/WSController/LobbyControl.cs +++ b/PayCheckServerLib/WSController/LobbyControl.cs @@ -163,7 +163,7 @@ public static void SendToLobby(Dictionary kv, PC3Session session { str += item.Key + ": " + item.Value + "\n"; } - str = str.Remove(str.Length -2); + str = str.Remove(str.Length - 1); Debugger.PrintWebsocket(str); session.SendBinaryAsync(str); }