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.
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
-
Method Details
-
handle
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 messagedata- the deserialized custom data
-