Files
DorkNet/DorkNet.Server/Controllers/API/GameSessions/V2/GameSessionsController.cs
T
Alexa d471b418b9 Import march-2020-03-10 from private repo (scrubbed 2026-05-27)
Targets Rec Room 2020.03.10 client (also serves 2020.03.06).

Re-import after adding:
- DorkNet.ClientMod/dorknet-clientmod.json.template — config schema
  the launcher's manifest-driven patcher renders into UserData/.
- tools/build-patcher-zip.ps1 — produces dorknet-clientpatch-{key}.zip
  for v1-march-* Release uploads.
- .github/workflows/release.yml — on tag push publishes both
  dorknet-server-march_2020_03_10-win-x64.zip and
  dorknet-clientpatch-march_2020_03_10.zip as Release assets.

Same scrub rules as december; tools/build-patcher-zip.ps1 added to
the maintainer-side allow-list so it survives.
2026-05-27 01:06:12 +03:00

68 lines
2.0 KiB
C#

using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using DorkNet.Models.GameSessions;
using DorkNet.Server.Auth;
using DorkNet.Server.Services;
namespace DorkNet.Server.Controllers.API.GameSessions.V2;
[ApiController]
[Route("api/[controller]/v2")]
[Authorize]
public class GameSessionsController(GameSessionService sessionService) : ControllerBase
{
private long CurrentPlayerId => this.RequireCurrentPlayerId();
[HttpPost("joinRandom")]
public async Task<ActionResult<JoinGameSessionResponse>> JoinRandom([FromBody] JoinRandomGameSessionRequest req)
{
var session = await sessionService.JoinOrCreateAsync(req.RoomId, req.ActivityLevelId, req.RegionId);
return Ok(new JoinGameSessionResponse
{
Result = JoinGameErrorCode.Success,
GameSession = session,
});
}
[HttpPost("joinById")]
public async Task<ActionResult<JoinGameSessionResponse>> JoinById([FromBody] JoinByIdRequest req)
{
var session = await sessionService.GetByIdAsync(req.GameSessionId);
if (session is null)
{
return Ok(new JoinGameSessionResponse { Result = JoinGameErrorCode.NotFound });
}
if (session.IsFull)
{
return Ok(new JoinGameSessionResponse { Result = JoinGameErrorCode.Full });
}
return Ok(new JoinGameSessionResponse
{
Result = JoinGameErrorCode.Success,
GameSession = session,
});
}
[HttpPost("leave")]
public async Task<ActionResult> Leave([FromBody] long sessionId)
{
await sessionService.PlayerLeftAsync(sessionId);
return Ok();
}
[HttpGet("{id:long}")]
public async Task<ActionResult<GameSession>> GetSession(long id)
{
var session = await sessionService.GetByIdAsync(id);
if (session is null) return NotFound();
return Ok(session);
}
}
public class JoinByIdRequest
{
public long GameSessionId { get; set; }
}