feat(battle-node): add IMsgBody marker + RawBody inbound wrapper
This commit is contained in:
10
SVSim.BattleNode/Protocol/IMsgBody.cs
Normal file
10
SVSim.BattleNode/Protocol/IMsgBody.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace SVSim.BattleNode.Protocol;
|
||||
|
||||
/// <summary>
|
||||
/// Marker for every type that can appear as <see cref="MsgEnvelope.Body"/>.
|
||||
/// Implementers fall into two camps: typed records used on the outbound path
|
||||
/// (one per scripted frame shape) and <see cref="RawBody"/> used on the inbound
|
||||
/// path. The marker exists so the envelope can carry either without falling
|
||||
/// back to <c>object</c>.
|
||||
/// </summary>
|
||||
public interface IMsgBody { }
|
||||
16
SVSim.BattleNode/Protocol/RawBody.cs
Normal file
16
SVSim.BattleNode/Protocol/RawBody.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
namespace SVSim.BattleNode.Protocol;
|
||||
|
||||
/// <summary>
|
||||
/// Wraps a parsed-dictionary body for the inbound path. <see cref="MsgEnvelope.FromJson"/>
|
||||
/// returns this; <see cref="MsgEnvelope.ToJson"/> flattens <see cref="Entries"/> back to
|
||||
/// top-level keys when echoing.
|
||||
/// </summary>
|
||||
public sealed class RawBody : IMsgBody
|
||||
{
|
||||
public Dictionary<string, object?> Entries { get; }
|
||||
|
||||
public RawBody(Dictionary<string, object?> entries)
|
||||
{
|
||||
Entries = entries;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user