Implement SOR.Ai Phase 1: project scaffold, transport, seeding, lobby handlers, session manager
- New SOR.Ai project with AI account/deck seeding (50 accounts: 10 difficulty × 5 strategy) - AiNoOpClientConnection + AiClientMessage: AI invokes game handlers in-process - AiPlayerSessionManager: BackgroundService subscribing to GameStarted/AiTurnStarted/GameEnded - AiPlayerSession: sends game.ready and executes turns (Phase 1 stub: pass immediately) - Lobby handlers: game.ai.add, game.ai.remove, game.ai.configure - IAiAccountRegistry in SOR.Shared to break circular dependency with SOR.Game - GameEndTurnHandler + GameReadyHandler publish AiTurnStarted event when AI is active player - Account entity: IsAi, AiDifficulty, AiStrategy columns - CustomLobby entity: AiSlotsJson column Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
namespace SOR.Ai.Transport;
|
||||
|
||||
using SOR.Networking.Abstractions.Messaging;
|
||||
|
||||
/// <summary>
|
||||
/// An IClientMessage constructed by the AI layer to call game handlers directly,
|
||||
/// bypassing the WebSocket transport entirely.
|
||||
///
|
||||
/// The payload must be pre-serialized as UTF-8 JSON using
|
||||
/// JsonSerializer.SerializeToUtf8Bytes(request), which is exactly what the Gateway
|
||||
/// WebSocket transport produces — so handlers see no difference.
|
||||
/// </summary>
|
||||
internal sealed class AiClientMessage : IClientMessage
|
||||
{
|
||||
public string Type { get; }
|
||||
public int Seq { get; }
|
||||
|
||||
public ReadOnlyMemory<byte> Payload { get; }
|
||||
|
||||
public AiClientMessage(string type, ReadOnlyMemory<byte> payload, int seq = 0)
|
||||
{
|
||||
Type = type;
|
||||
Seq = seq;
|
||||
Payload = payload;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user