Package de.frzy.darelay
Class DaRelaySender
java.lang.Object
de.frzy.darelay.DaRelaySender
Publishes messages to Valkey/Redis channels.
Uses the settings from DaRelayListener.connect(java.lang.String, int, java.lang.String, java.lang.String, boolean) automatically, or call
init(java.lang.String, int, java.lang.String, java.lang.String, boolean) yourself on a server that only sends.
send(java.lang.String, java.lang.String) blocks on the network (up to 5 s if Valkey is down), so from a
game's main thread prefer sendAsync(java.lang.String, java.lang.String).
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidclose()Close the sending connection and forget the settings.static voidConfigure the sender explicitly.static longPublish a message.static CompletableFuture<Long> Same assend(java.lang.String, java.lang.String), but runs off the calling thread.
-
Method Details
-
init
Configure the sender explicitly. Only needed if you never call DaRelayListener.connect(). -
send
Publish a message. Returns how many subscribers received it. Retries once on a fresh connection if the old one went stale.- Throws:
UncheckedIOException- if Valkey can't be reachedIllegalStateException- if neither init() nor DaRelayListener.connect() was called
-
sendAsync
Same assend(java.lang.String, java.lang.String), but runs off the calling thread. -
close
public static void close()Close the sending connection and forget the settings. Called by DaRelayListener.shutdown().
-