FCommMessage Structure and Design - wwestlake/Steamforge GitHub Wiki

FCommMessage Structure and Design

📦 Overview

The FCommMessage struct models a game communication message as a transport-friendly, extensible object with a clear separation between routing metadata (the envelope) and opaque content (the payload).

This pattern mirrors internet protocols like HTTP and SMTP: structured headers + flexible message bodies.


📢 Metadata Envelope (Known Structure)

Used for routing, filtering, tracking, and system-wide logic.

FName SenderID;         // ID of the component sending the message
FName TargetID;         // Optional: direct recipient if private
FName ChannelID;        // Optional: for broadcasting via channels
FName MessageType;      // DataTable-driven message type identifier
FDateTime Timestamp;    // When the message was generated

✅ Characteristics:

  • Consistent across all messages
  • Understood by the CommunicationCenter and all listeners
  • MessageType is a DataTable lookup, not an enum

📥 Payload Body (Opaque Content)

Used to carry arbitrary message data, interpreted only by receivers.

FString PayloadJSON;

✅ Characteristics:

  • Can encode structured game data (e.g., JSON, serialized maps)
  • Allows actor-specific or component-specific behavior
  • Encourages separation of transport and interpretation

🚀 Example Payload:

{
  "Weather": "Rain",
  "Intensity": 0.7,
  "Region": "EastField"
}

⚖️ Benefits

  • Decouples sender and receiver logic
  • Enables dynamic routing, filtering, and logging
  • Facilitates future enhancements (e.g., TTL, priorities)
  • Allows subsystem-to-subsystem messaging without coupling

⚡ Future Enhancements (Optional)

  • Add Priority, Flags, TimeToLive to the envelope
  • Support for schema validation of payload
  • Add PayloadType hint for deserialization logic (if needed)

✅ Next Step Suggestions

  • Define FCommMessage as a USTRUCT
  • Create sample payload structures and receivers
  • Define MessageType DataTable schema and usage patterns