From e6c9761647581652ea150da3267b2a1eaac9387b Mon Sep 17 00:00:00 2001 From: HttpMarco Date: Sat, 13 Jul 2024 15:28:12 +0200 Subject: [PATCH] Fix client requests --- build.gradle.kts | 2 +- .../client/CommunicationClientTransmit.java | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index e624df6..e04e65d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,7 +10,7 @@ allprojects { apply(plugin = "maven-publish") group = "dev.httpmarco" - version = "1.2.5-SNAPSHOT" + version = "1.2.13-SNAPSHOT" repositories { mavenCentral() diff --git a/osgan-netty/src/main/java/dev/httpmarco/osgan/networking/client/CommunicationClientTransmit.java b/osgan-netty/src/main/java/dev/httpmarco/osgan/networking/client/CommunicationClientTransmit.java index 6dfa7b1..87d7639 100644 --- a/osgan-netty/src/main/java/dev/httpmarco/osgan/networking/client/CommunicationClientTransmit.java +++ b/osgan-netty/src/main/java/dev/httpmarco/osgan/networking/client/CommunicationClientTransmit.java @@ -1,12 +1,15 @@ package dev.httpmarco.osgan.networking.client; import dev.httpmarco.osgan.networking.CommunicationComponent; +import dev.httpmarco.osgan.networking.CommunicationProperty; import dev.httpmarco.osgan.networking.channel.ChannelTransmit; import dev.httpmarco.osgan.networking.packet.Packet; import io.netty5.channel.Channel; +import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import java.util.function.Consumer; +import java.util.function.Function; public final class CommunicationClientTransmit extends ChannelTransmit { @@ -27,11 +30,22 @@ public

void listen(Class

listeningClass, Consumer

packe communicationComponent.listen(listeningClass, packetCallback); } - public static CommunicationClientTransmit empty(CommunicationComponent communicationComponent) { + @Override + public void responder(String id, Function packetFunction) { + this.communicationComponent.responder(id, packetFunction); + } + + @Override + public

void request(String id, CommunicationProperty property, Class

packet, Consumer

packetCallback) { + this.communicationComponent.request(id, property, packet, packetCallback); + } + + @Contract("_ -> new") + public static @NotNull CommunicationClientTransmit empty(CommunicationComponent communicationComponent) { return new CommunicationClientTransmit(communicationComponent, null, null); } - public static CommunicationClientTransmit of(CommunicationComponent communicationComponent, ChannelTransmit transmit) { + public static @NotNull CommunicationClientTransmit of(CommunicationComponent communicationComponent, @NotNull ChannelTransmit transmit) { var clientTransmit = new CommunicationClientTransmit(communicationComponent, transmit.id(), transmit.channel()); clientTransmit.listeners().putAll(transmit.listeners()); clientTransmit.requests().putAll(transmit.requests());