Record Class PluginMessage

java.lang.Object
java.lang.Record
me.internalizable.numdrassl.api.messaging.message.PluginMessage
Record Components:
sourceProxyId - the proxy that sent the message
timestamp - when the message was created
pluginId - unique identifier of the sending plugin
channel - sub-channel within the plugin namespace
payload - 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:

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 Details

    • PluginMessage

      public PluginMessage(@Nonnull String sourceProxyId, @Nonnull Instant timestamp, @Nonnull String pluginId, @Nonnull String channel, @Nonnull String payload)
      Creates an instance of a PluginMessage record class.
      Parameters:
      sourceProxyId - the value for the sourceProxyId record component
      timestamp - the value for the timestamp record component
      pluginId - the value for the pluginId record component
      channel - the value for the channel record component
      payload - the value for the payload 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
    • pluginId

      @Nonnull public String pluginId()
      Returns the value of the pluginId record component.
      Returns:
      the value of the pluginId record component
    • channel

      @Nonnull public String channel()
      Returns the value of the channel record component.
      Returns:
      the value of the channel record component
    • payload

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