Record Class PluginMessage
java.lang.Object
java.lang.Record
me.internalizable.numdrassl.api.messaging.message.PluginMessage
- Record Components:
sourceProxyId- the proxy that sent the messagetimestamp- when the message was createdpluginId- unique identifier of the sending pluginchannel- sub-channel within the plugin namespacepayload- JSON-serialized data payload
- All Implemented Interfaces:
ChannelMessage
public record PluginMessage(@Nonnull String sourceProxyId, @Nonnull Instant timestamp, @Nonnull String pluginId, @Nonnull String channel, @Nonnull String payload)
extends Record
implements ChannelMessage
Plugin-defined custom message for cross-proxy communication.
This message type allows plugins to send arbitrary data between proxy instances. The payload is serialized to JSON.
For most use cases, prefer the higher-level API:
MessagingService.publishPlugin(String, String, Object)MessagingService.subscribePlugin(String, String, Class, PluginMessageHandler)@MessageSubscribeannotation
Example
// High-level API (recommended)
messaging.publishPlugin("my-plugin", "events", myData);
// Low-level API
PluginMessage msg = new PluginMessage(
proxyId, Instant.now(),
"my-plugin", "events",
gson.toJson(myData)
);
messaging.publish(Channels.PLUGIN, msg);
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionchannel()Returns the value of thechannelrecord 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.payload()Returns the value of thepayloadrecord component.pluginId()Returns the value of thepluginIdrecord component.Returns the value of thesourceProxyIdrecord component.Returns the value of thetimestamprecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
PluginMessage
public PluginMessage(@Nonnull String sourceProxyId, @Nonnull Instant timestamp, @Nonnull String pluginId, @Nonnull String channel, @Nonnull String payload) Creates an instance of aPluginMessagerecord class.- Parameters:
sourceProxyId- the value for thesourceProxyIdrecord componenttimestamp- the value for thetimestamprecord componentpluginId- the value for thepluginIdrecord componentchannel- the value for thechannelrecord componentpayload- the value for thepayloadrecord 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
-
pluginId
-
channel
-
payload
-