Record Class BroadcastMessage
java.lang.Object
java.lang.Record
me.internalizable.numdrassl.api.messaging.message.BroadcastMessage
- Record Components:
sourceProxyId- the proxy that initiated the broadcasttimestamp- when the broadcast was createdbroadcastType- 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 Summary
ConstructorsConstructorDescriptionBroadcastMessage(String sourceProxyId, Instant timestamp, String broadcastType, String content) Creates an instance of aBroadcastMessagerecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thebroadcastTyperecord component.content()Returns the value of thecontentrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Get the message type identifier for serialization.Returns the value of thesourceProxyIdrecord component.Returns the value of thetimestamprecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
BroadcastMessage
public BroadcastMessage(@Nonnull String sourceProxyId, @Nonnull Instant timestamp, @Nonnull String broadcastType, @Nonnull String content) Creates an instance of aBroadcastMessagerecord class.- Parameters:
sourceProxyId- the value for thesourceProxyIdrecord componenttimestamp- the value for thetimestamprecord componentbroadcastType- the value for thebroadcastTyperecord componentcontent- the value for thecontentrecord component
-
-
Method Details
-
messageType
Description copied from interface:ChannelMessageGet the message type identifier for serialization.- Specified by:
messageTypein interfaceChannelMessage- Returns:
- the message type (e.g., "heartbeat", "chat", "plugin")
-
toString
-
hashCode
-
equals
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 withObjects::equals(Object,Object). -
sourceProxyId
Returns the value of thesourceProxyIdrecord component.- Specified by:
sourceProxyIdin interfaceChannelMessage- Returns:
- the value of the
sourceProxyIdrecord component
-
timestamp
Returns the value of thetimestamprecord component.- Specified by:
timestampin interfaceChannelMessage- Returns:
- the value of the
timestamprecord component
-
broadcastType
Returns the value of thebroadcastTyperecord component.- Returns:
- the value of the
broadcastTyperecord component
-
content
-