Skip to content

Commit

Permalink
fix lobby stuff, maybe fix challanges
Browse files Browse the repository at this point in the history
  • Loading branch information
SlejmUr committed Sep 19, 2023
1 parent d4cacd8 commit e04bac7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 20 deletions.
17 changes: 0 additions & 17 deletions PayCheckServerLib/Responses/Challenge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<DataPaging<ChallengesData>>(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)
{
Expand Down
10 changes: 8 additions & 2 deletions PayCheckServerLib/Servers/PC3Server.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using NetCoreServer;
using PayCheckServerLib.Helpers;
using PayCheckServerLib.Responses;
using PayCheckServerLib.WSController;
using System.Net.Sockets;
using System.Reflection;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion PayCheckServerLib/WSController/LobbyControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public static void SendToLobby(Dictionary<string, string> 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);
}
Expand Down

0 comments on commit e04bac7

Please sign in to comment.