Interface MessageChannel.Sender<P extends ChannelPayload>
- Type Parameters:
P- the payload type this sender dispatches; must extendChannelPayload
- Enclosing interface:
MessageChannel<P extends ChannelPayload>
MessageChannel.to(java.util.Collection) or
MessageChannel.toAll(), used to dispatch payloads to the targeted
servers.
Obtain a Sender by calling one of the MessageChannel target
methods.
Send a payload with send(ChannelPayload) for fire-and-forget
delivery, or use
request(ChannelPayload) for request-response patterns. Optional
delivery conditions
can be set with requirePlayer(UUID) and whenOnline(UUID).
-
Method Summary
Modifier and TypeMethodDescriptionSends a payload and returns a future that completes with the remote server's response, using the default timeout.Sends a payload and returns a future that completes with the remote server's response, using a custom timeout.default MessageChannel.Sender<P> Constrains this sender to only execute if the triggering player (if any) is present on the target server at the time of delivery.default MessageChannel.Sender<P> requirePlayer(UUID player) Constrains this sender to only execute if the specified player is present on the target server at the time of delivery.Sends a payload to the targeted servers without waiting for a response.default MessageChannel.Sender<P> Queues the payload for delivery to the target server when the triggering player (if any) is online.default MessageChannel.Sender<P> whenOnline(UUID player) Queues the payload for delivery to the target server when the specified player is online.
-
Method Details
-
send
Sends a payload to the targeted servers without waiting for a response.- Parameters:
payload- the payload to send; must not benull- Returns:
- a
CompletableFuture<Void>that completes when the payload has been dispatched (not when it has been received or processed by the remote server)
-
request
Sends a payload and returns a future that completes with the remote server's response, using the default timeout.This method is only supported for single-target senders. Invoking it on a multi-target sender throws
UnsupportedOperationException.- Parameters:
payload- the request payload; must not benull- Returns:
- a
CompletableFuturethat completes with the response payload, or completes exceptionally if the default timeout elapses before a response is received - Throws:
UnsupportedOperationException- if this sender targets more than one server- See Also:
-
request
Sends a payload and returns a future that completes with the remote server's response, using a custom timeout.This method is only supported for single-target senders. Invoking it on a multi-target sender throws
UnsupportedOperationException.- Parameters:
payload- the request payload; must not benulltimeout- the maximum duration to wait for a response; must not benull- Returns:
- a
CompletableFuturethat completes with the response payload, or completes exceptionally if the timeout elapses - Throws:
UnsupportedOperationException- if this sender targets more than one server- See Also:
-
requirePlayer
Constrains this sender to only execute if the specified player is present on the target server at the time of delivery.If the player is not present, the command is not delivered to that server. Use
whenOnline(UUID)instead if queued delivery when the player connects is desired.- Parameters:
player- the UUID of the player whose presence is required; must not benull- Returns:
- this sender for method chaining
- Throws:
UnsupportedOperationException- if this sender implementation does not support player-conditioned delivery (the default implementation always throws)- See Also:
-
requirePlayer
Constrains this sender to only execute if the triggering player (if any) is present on the target server at the time of delivery.This is the no-argument variant of
requirePlayer(UUID); it uses the player associated with the execution context rather than an explicit UUID.- Returns:
- this sender for method chaining
- Throws:
UnsupportedOperationException- if this sender implementation does not support player-conditioned delivery (the default implementation always throws)- See Also:
-
whenOnline
Queues the payload for delivery to the target server when the specified player is online.Unlike
requirePlayer(UUID), which skips delivery if the player is absent, this method queues the payload and delivers it once the player connects to the target server.- Parameters:
player- the UUID of the player to wait for; must not benull- Returns:
- this sender for method chaining
- Throws:
UnsupportedOperationException- if this sender implementation does not support queued delivery (the default implementation always throws)- See Also:
-
whenOnline
Queues the payload for delivery to the target server when the triggering player (if any) is online.This is the no-argument variant of
whenOnline(UUID); it uses the player associated with the execution context rather than an explicit UUID.- Returns:
- this sender for method chaining
- Throws:
UnsupportedOperationException- if this sender implementation does not support queued delivery (the default implementation always throws)- See Also:
-