Interface ProxySender
public interface ProxySender
Sends messages and data across proxy network connections.
Usage example:
ProxySender proxySender = flectonePulse.get(ProxySender.class);
// Send message across proxy network
proxySender.send(MessageType.CHAT, eventMetadata);
// Send custom data to proxy
proxySender.send(sender, MessageType.CUSTOM, output -> {
output.writeUTF("custom data");
}, UUID.randomUUID());
- Since:
- 1.0.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidsend(byte @NonNull [] data, @NonNull Consumer<byte[]> dataConsumer, @NonNull Consumer<UUID> backendJoinConfirm) Reads a message off the proxy channel and either forwards it on or handles it as a join confirmation.booleansend(@NonNull ModuleName moduleName, @NonNull EventMetadata eventMetadata, @NonNull MessageContext messageContext) Sends event metadata to proxy network.static voidsend(@NonNull ModuleName tag, @NonNull ProxyDataConsumer<DataOutputStream> outputConsumer, @NonNull Consumer<byte[]> dataConsumer) Encodes a message for the proxy channel and hands it to the transport.booleansend(@NonNull FEntity sender, @NonNull ModuleName tag) Sends a simple message to proxy network.booleansend(@NonNull FEntity sender, @NonNull ModuleName tag, @NonNull ProxyDataConsumer<DataOutputStream> outputConsumer) Sends a simple message to proxy network.booleansend(@NonNull FEntity sender, @NonNull ModuleName tag, @NonNull ProxyDataConsumer<DataOutputStream> outputConsumer, @NonNull UUID metadataUUID) Sends custom data to proxy network.
-
Method Details
-
send
static void send(byte @NonNull [] data, @NonNull Consumer<byte[]> dataConsumer, @NonNull Consumer<UUID> backendJoinConfirm) Reads a message off the proxy channel and either forwards it on or handles it as a join confirmation.- Parameters:
data- the raw payloaddataConsumer- forwards the payload to the servers that should see itbackendJoinConfirm- receives the player id when the message is a join confirmation
-
send
static void send(@NonNull ModuleName tag, @NonNull ProxyDataConsumer<DataOutputStream> outputConsumer, @NonNull Consumer<byte[]> dataConsumer) Encodes a message for the proxy channel and hands it to the transport.- Parameters:
tag- the module the message belongs tooutputConsumer- writes the payloaddataConsumer- receives the encoded bytes
-
send
boolean send(@NonNull ModuleName moduleName, @NonNull EventMetadata eventMetadata, @NonNull MessageContext messageContext) Sends event metadata to proxy network.- Parameters:
moduleName- the type of message being senteventMetadata- the event metadata containing sender and datamessageContext- The message context containing sender details and unique message identifier- Returns:
- true if message was sent to at least one proxy, false otherwise
-
send
Sends a simple message to proxy network.- Parameters:
sender- the entity sending the messagetag- the message type tag- Returns:
- true if message was sent to at least one proxy, false otherwise
-
send
boolean send(@NonNull FEntity sender, @NonNull ModuleName tag, @NonNull ProxyDataConsumer<DataOutputStream> outputConsumer) Sends a simple message to proxy network.- Parameters:
sender- the entity sending the messagetag- the message type tagoutputConsumer- consumer to write custom data to output stream- Returns:
- true if message was sent to at least one proxy, false otherwise
-
send
boolean send(@NonNull FEntity sender, @NonNull ModuleName tag, @NonNull ProxyDataConsumer<DataOutputStream> outputConsumer, @NonNull UUID metadataUUID) Sends custom data to proxy network.- Parameters:
sender- the entity sending the datatag- the message type tagoutputConsumer- consumer to write custom data to output streammetadataUUID- unique identifier for this metadata- Returns:
- true if data was sent to at least one proxy, false otherwise
-