Clarify sample payloads in CultNet
This commit is contained in:
parent
c627200e4a
commit
73a30052c7
4 changed files with 91 additions and 23 deletions
24
src/GameCult.Networking/Samples/README.md
Normal file
24
src/GameCult.Networking/Samples/README.md
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
# Sample Payload Messages
|
||||
|
||||
`ChangeNameMessage` and `ChatMessage` are example application payloads.
|
||||
|
||||
They are kept in the base union because they are useful for smoke tests, sample
|
||||
client/server code, and cross-runtime compatibility checks. They are not meant
|
||||
to imply that CultNet itself is only for game chat or lobby glue.
|
||||
|
||||
The actual durable contract is:
|
||||
|
||||
- transport + framing
|
||||
- encryption and verify/login/register session flow
|
||||
- shared MessagePack message layout
|
||||
|
||||
Applications should define their own domain messages with the same discipline
|
||||
used by CultCache document contracts:
|
||||
|
||||
- explicit field keys
|
||||
- stable tag assignments
|
||||
- shared definitions across runtimes
|
||||
- no casual drift between language bindings
|
||||
|
||||
If two apps share a message contract, they should be able to share data without
|
||||
translating through bespoke middleware fog. That is the point.
|
||||
38
src/GameCult.Networking/Samples/SamplePayloadMessages.cs
Normal file
38
src/GameCult.Networking/Samples/SamplePayloadMessages.cs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
using MessagePack;
|
||||
|
||||
namespace GameCult.Networking
|
||||
{
|
||||
/// <summary>
|
||||
/// Sample authenticated payload for changing a player-visible name.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is example application payload riding the shared networking contract,
|
||||
/// not a claim that CultNet itself is spiritually about chat lobbies forever.
|
||||
/// Keep the wire tag stable if other runtimes depend on it.
|
||||
/// </remarks>
|
||||
[MessagePackObject]
|
||||
public class ChangeNameMessage : Message
|
||||
{
|
||||
/// <summary>
|
||||
/// Requested new username.
|
||||
/// </summary>
|
||||
[Key(0)] public string Name = string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sample plain chat payload.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This exists as a dead-simple reference payload for message extension and
|
||||
/// cross-runtime compatibility tests. Real applications should define their
|
||||
/// own domain messages and keep those contracts in sync across languages.
|
||||
/// </remarks>
|
||||
[MessagePackObject]
|
||||
public class ChatMessage : Message
|
||||
{
|
||||
/// <summary>
|
||||
/// Chat text content.
|
||||
/// </summary>
|
||||
[Key(0)] public string Text = string.Empty;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue