Interface PluginMessageHandler<T>

Type Parameters:
T - the custom data type
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface PluginMessageHandler<T>
Handler for typed plugin messages received from other proxy instances.

This functional interface is used with MessagingService.subscribePlugin(String, String, Class, PluginMessageHandler) to receive custom plugin data with automatic deserialization.

Example

// Define your custom data type
record ScoreData(String playerName, int score) {}

// Create a handler
PluginMessageHandler<ScoreData> handler = (sourceProxyId, data) -> {
    logger.info("Player {} scored {} (from proxy {})",
        data.playerName(), data.score(), sourceProxyId);
};

// Subscribe
messaging.subscribePlugin("my-plugin", "scores", ScoreData.class, handler);
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    handle(String sourceProxyId, T data)
    Handle a received plugin message.
  • Method Details

    • handle

      void handle(@Nonnull String sourceProxyId, @Nonnull T data)
      Handle a received plugin message.

      This method is invoked on a message handling thread. Implementations should not block for extended periods.

      Parameters:
      sourceProxyId - the ID of the proxy that sent the message
      data - the deserialized custom data