Package wtf.choco.dyson4j.mqtt
Interface ICompoundMqttActionListener
- All Superinterfaces:
org.eclipse.paho.client.mqttv3.IMqttActionListener
- 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 ICompoundMqttActionListener
extends org.eclipse.paho.client.mqttv3.IMqttActionListener
An
IMqttActionListener
that handles both successes and failures in a single method
invocation as a FunctionalInterface
.-
Method Summary
Modifier and TypeMethodDescriptionvoid
handle
(@NotNull org.eclipse.paho.client.mqttv3.IMqttToken token, @NotNull Optional<Throwable> exception) Handle an MQTT action.static @NotNull org.eclipse.paho.client.mqttv3.IMqttActionListener
of
(@NotNull ICompoundMqttActionListener listener) A utility method to satisfy the compiler where instances ofIMqttActionListener
are required by library methods, but anICompoundMqttActionListener
is used.default void
default void
onSuccess
(org.eclipse.paho.client.mqttv3.IMqttToken asyncActionToken)
-
Method Details
-
handle
void handle(@NotNull @NotNull org.eclipse.paho.client.mqttv3.IMqttToken token, @NotNull @NotNull Optional<Throwable> exception) Handle an MQTT action.This method will be called for both successes and failures. The
token
will always be available, but theexception
will be present depending on whether or not the action succeeded or failed. If it failed, the optional will contain the exception that was thrown as a result of the failure.- Parameters:
token
- the action tokenexception
- an optional containing the exception that may or may not have been thrown. If the action was a success, this optional will be empty
-
onSuccess
default void onSuccess(org.eclipse.paho.client.mqttv3.IMqttToken asyncActionToken) - Specified by:
onSuccess
in interfaceorg.eclipse.paho.client.mqttv3.IMqttActionListener
-
onFailure
default void onFailure(org.eclipse.paho.client.mqttv3.IMqttToken asyncActionToken, Throwable exception) - Specified by:
onFailure
in interfaceorg.eclipse.paho.client.mqttv3.IMqttActionListener
-
of
@NotNull static @NotNull org.eclipse.paho.client.mqttv3.IMqttActionListener of(@NotNull @NotNull ICompoundMqttActionListener listener) A utility method to satisfy the compiler where instances ofIMqttActionListener
are required by library methods, but anICompoundMqttActionListener
is used.This is sneaky :)
- Parameters:
listener
- the listener- Returns:
- the listener as an IMqttActionListener
-