public interface Transport
| Modifier and Type | Field and Description |
|---|---|
static java.util.concurrent.ExecutorService |
POOL
A thread pool from which to run tasks.
|
| Modifier and Type | Method and Description |
|---|---|
void |
bind(UDPBroadcastProtos.MessageType channel,
java.util.function.Consumer<byte[]> listener)
Bind a consumer to this transport, to listen on incoming messages.
|
boolean |
broadcastTransport(UDPBroadcastProtos.MessageType messageType,
byte[] message)
Broadcast a message to everyone listening on the transport.
|
default void |
doAction(boolean async,
java.lang.String description,
java.lang.Runnable action)
Do a given action.
|
boolean |
sendTransport(java.lang.String destination,
UDPBroadcastProtos.MessageType messageType,
byte[] message)
Send a message on the transport.
|
static final java.util.concurrent.ExecutorService POOL
void bind(UDPBroadcastProtos.MessageType channel, java.util.function.Consumer<byte[]> listener)
channel - The type of message we're listing for.listener - The listener, taking as input a raw byte stream.boolean sendTransport(java.lang.String destination,
UDPBroadcastProtos.MessageType messageType,
byte[] message)
destination - The location we're sending the message to. This is transport-dependent, but is often
the IP address of the destination.messageType - The type of message we're sending. This should match the channel in bind(UDPBroadcastProtos.MessageType, Consumer).message - The message, as a raw byte stream.boolean broadcastTransport(UDPBroadcastProtos.MessageType messageType, byte[] message)
messageType - The type of message we're sending. This should match the channel in bind(UDPBroadcastProtos.MessageType, Consumer).message - The message, as a raw byte stream.default void doAction(boolean async,
java.lang.String description,
java.lang.Runnable action)
async - If true, run the action asynchronously on POOL.description - A human-readable description of the actionaction - The action to perform.