Record Class BroadcastMessage

java.lang.Object
java.lang.Record
me.internalizable.numdrassl.api.messaging.message.BroadcastMessage
Record Components:
sourceProxyId - the proxy that initiated the broadcast
timestamp - when the broadcast was created
broadcastType - categorization of the broadcast (e.g., "announcement", "alert")
content - the broadcast message content
All Implemented Interfaces:
ChannelMessage

public record BroadcastMessage(@Nonnull String sourceProxyId, @Nonnull Instant timestamp, @Nonnull String broadcastType, @Nonnull String content) extends Record implements ChannelMessage
Cluster-wide broadcast message for announcements to all proxies.

Used for messages that need to reach all proxy instances, such as:

  • Server-wide announcements
  • Maintenance notifications
  • Emergency alerts
  • Configuration updates

Usage

// Send a broadcast
BroadcastMessage broadcast = new BroadcastMessage(
    proxyId, Instant.now(),
    "announcement",
    "Server restarting in 5 minutes!"
);
messaging.publish(Channels.BROADCAST, broadcast);

// Subscribe to broadcasts
@Subscribe(SystemChannel.BROADCAST)
public void onBroadcast(BroadcastMessage msg) {
    if ("announcement".equals(msg.broadcastType())) {
        broadcastToAllPlayers(msg.content());
    }
}
  • Constructor Details

    • BroadcastMessage

      public BroadcastMessage(@Nonnull String sourceProxyId, @Nonnull Instant timestamp, @Nonnull String broadcastType, @Nonnull String content)
      Creates an instance of a BroadcastMessage record class.
      Parameters:
      sourceProxyId - the value for the sourceProxyId record component
      timestamp - the value for the timestamp record component
      broadcastType - the value for the broadcastType record component
      content - the value for the content record component
  • Method Details

    • messageType

      @Nonnull public String messageType()
      Description copied from interface: ChannelMessage
      Get the message type identifier for serialization.
      Specified by:
      messageType in interface ChannelMessage
      Returns:
      the message type (e.g., "heartbeat", "chat", "plugin")
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • sourceProxyId

      @Nonnull public String sourceProxyId()
      Returns the value of the sourceProxyId record component.
      Specified by:
      sourceProxyId in interface ChannelMessage
      Returns:
      the value of the sourceProxyId record component
    • timestamp

      @Nonnull public Instant timestamp()
      Returns the value of the timestamp record component.
      Specified by:
      timestamp in interface ChannelMessage
      Returns:
      the value of the timestamp record component
    • broadcastType

      @Nonnull public String broadcastType()
      Returns the value of the broadcastType record component.
      Returns:
      the value of the broadcastType record component
    • content

      @Nonnull public String content()
      Returns the value of the content record component.
      Returns:
      the value of the content record component