Improved accuracy of client/match/join and client/match/group/start_game

This commit is contained in:
Chomp
2025-06-26 11:14:24 +01:00
parent af5f8bfdbc
commit c91b6c4407
4 changed files with 58 additions and 14 deletions
@@ -183,14 +183,10 @@ public class MatchCallbacks(
/// Handle match/group/start_game
/// </summary>
/// <returns></returns>
public ValueTask<string> JoinMatch(
string url,
MatchGroupStartGameRequest info,
string sessionID
)
public ValueTask<string> JoinMatch(string url, MatchGroupJoinRequest request, string sessionID)
{
return new ValueTask<string>(
_httpResponseUtil.GetBody(_matchController.JoinMatch(info, sessionID))
_httpResponseUtil.GetBody(_matchController.JoinMatch(request, sessionID))
);
}
@@ -332,4 +328,17 @@ public class MatchCallbacks(
{
return new ValueTask<string>(_httpResponseUtil.GetBody(true));
}
/// <summary>
/// Handle client/match/group/start_game
/// </summary>
public Task<string> StartGameAsGroupLeader(
string url,
MatchGroupStartGameRequest? request,
string? sessionId
)
{
// returns a ProfileStatusResponse object
throw new NotImplementedException();
}
}
@@ -2,7 +2,6 @@ using SPTarkov.DI.Annotations;
using SPTarkov.Server.Core.Helpers;
using SPTarkov.Server.Core.Models.Eft.Match;
using SPTarkov.Server.Core.Models.Spt.Config;
using SPTarkov.Server.Core.Models.Spt.Services;
using SPTarkov.Server.Core.Models.Utils;
using SPTarkov.Server.Core.Servers;
using SPTarkov.Server.Core.Services;
@@ -14,7 +13,6 @@ namespace SPTarkov.Server.Core.Controllers;
[Injectable]
public class MatchController(
ISptLogger<MatchController> _logger,
SaveServer _saveServer,
MatchLocationService _matchLocationService,
ConfigServer _configServer,
LocationLifecycleService _locationLifecycleService,
@@ -23,8 +21,8 @@ public class MatchController(
ICloner _cloner
)
{
protected MatchConfig _matchConfig = _configServer.GetConfig<MatchConfig>();
protected PmcConfig _pmcConfig = _configServer.GetConfig<PmcConfig>();
protected readonly MatchConfig _matchConfig = _configServer.GetConfig<MatchConfig>();
protected readonly PmcConfig _pmcConfig = _configServer.GetConfig<PmcConfig>();
/// <summary>
/// Handle client/match/available
@@ -50,7 +48,7 @@ public class MatchController(
/// <param name="request">Start game request</param>
/// <param name="sessionId">Session/Player id</param>
/// <returns>ProfileStatusResponse</returns>
public ProfileStatusResponse JoinMatch(MatchGroupStartGameRequest request, string sessionId)
public ProfileStatusResponse JoinMatch(MatchGroupJoinRequest request, string sessionId)
{
var output = new ProfileStatusResponse
{
@@ -0,0 +1,37 @@
using System.Text.Json.Serialization;
using SPTarkov.Server.Core.Models.Utils;
namespace SPTarkov.Server.Core.Models.Eft.Match;
public record MatchGroupJoinRequest : IRequestData
{
[JsonExtensionData]
public Dictionary<string, object>? ExtensionData { get; set; }
[JsonPropertyName("location")]
public string? Location { get; set; }
[JsonPropertyName("savage")]
public bool? Savage { get; set; }
[JsonPropertyName("dt")]
public string? Dt { get; set; }
[JsonPropertyName("servers")]
public List<JoinServer>? Servers { get; set; }
[JsonPropertyName("keyId")]
public string? KeyId { get; set; }
}
public record JoinServer
{
[JsonPropertyName("ping")]
public int? Ping { get; set; }
[JsonPropertyName("ip")]
public string? Ip { get; set; }
[JsonPropertyName("port")]
public string? Port { get; set; }
}
@@ -39,10 +39,10 @@ public class MatchStaticRouter : StaticRouter
async (url, info, sessionID, output) =>
await matchCallbacks.JoinMatch(
url,
info as MatchGroupStartGameRequest,
info as MatchGroupJoinRequest,
sessionID
),
typeof(MatchGroupStartGameRequest)
typeof(MatchGroupJoinRequest)
),
new RouteAction(
"/client/match/exit",
@@ -72,7 +72,7 @@ public class MatchStaticRouter : StaticRouter
new RouteAction(
"/client/match/group/start_game",
async (url, info, sessionID, output) =>
await matchCallbacks.JoinMatch(
await matchCallbacks.StartGameAsGroupLeader(
url,
info as MatchGroupStartGameRequest,
sessionID