WIP phase 39: school owners, my/others menu, guest restrictions.
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user