WIP phase 39: school owners, my/others menu, guest restrictions.

This commit is contained in:
Leonid Pershin
2026-08-20 07:58:12 +03:00
parent 40929aa3ce
commit 26be7c87f8
27 changed files with 919 additions and 81 deletions
+19 -3
View File
@@ -2,6 +2,7 @@ using System.Buffers;
using System.Net.WebSockets;
using HSchool.Protocol;
using HSchool.Server.Game;
using HSchool.Simulation;
namespace HSchool.Server.Net;
@@ -146,16 +147,28 @@ internal sealed class GameSocketHandler(
case MessageType.ClientSetRunning:
var setRunning = ProtocolCodec.ReadSetRunning(frame);
commands.Enqueue(new GameCommand.SetRunning(client.PlayerId, setRunning.Running));
if (TryNormalizedUser(client, out var runningUser))
{
commands.Enqueue(new GameCommand.SetRunning(client.PlayerId, setRunning.Running, runningUser));
}
break;
case MessageType.ClientSetSpeed:
var setSpeed = ProtocolCodec.ReadSetSpeed(frame);
commands.Enqueue(new GameCommand.SetSpeed(client.PlayerId, setSpeed.SpeedIndex));
if (TryNormalizedUser(client, out var speedUser))
{
commands.Enqueue(new GameCommand.SetSpeed(client.PlayerId, setSpeed.SpeedIndex, speedUser));
}
break;
case MessageType.ClientSkipEmpty:
commands.Enqueue(new GameCommand.SkipEmpty(client.PlayerId));
if (TryNormalizedUser(client, out var skipUser))
{
commands.Enqueue(new GameCommand.SkipEmpty(client.PlayerId, skipUser));
}
break;
default:
@@ -227,6 +240,9 @@ internal sealed class GameSocketHandler(
client.TrySend(frame.AsMemory(0, length));
}
private static bool TryNormalizedUser(GameClient client, out string normalized) =>
SchoolNames.TryNormalize(client.UserName, out normalized);
private static async Task CloseAsync(
WebSocket socket,
WebSocketCloseStatus status,