Skip to content

Commit

Permalink
Fix client requests
Browse files Browse the repository at this point in the history
  • Loading branch information
HttpMarco committed Jul 13, 2024
1 parent f5fe8ac commit e6c9761
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ allprojects {
apply(plugin = "maven-publish")

group = "dev.httpmarco"
version = "1.2.5-SNAPSHOT"
version = "1.2.13-SNAPSHOT"

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {

Expand All @@ -27,11 +30,22 @@ public <P extends Packet> void listen(Class<P> listeningClass, Consumer<P> packe
communicationComponent.listen(listeningClass, packetCallback);
}

public static CommunicationClientTransmit empty(CommunicationComponent communicationComponent) {
@Override
public void responder(String id, Function<CommunicationProperty, Packet> packetFunction) {
this.communicationComponent.responder(id, packetFunction);
}

@Override
public <P extends Packet> void request(String id, CommunicationProperty property, Class<P> packet, Consumer<P> 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());
Expand Down

0 comments on commit e6c9761

Please sign in to comment.