io.github.sinri.keel.web.udp.KeelUDPTransceiver Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Keel Show documentation
Show all versions of Keel Show documentation
A website framework with VERT.X for ex-PHP-ers, exactly Ark Framework Users.
The newest version!
package io.github.sinri.keel.web.udp;
import io.github.sinri.keel.logger.issue.recorder.KeelIssueRecorder;
import io.vertx.core.Future;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.datagram.DatagramSocket;
import io.vertx.core.net.SocketAddress;
import javax.annotation.Nonnull;
import java.util.Objects;
import java.util.function.BiConsumer;
/**
* @since 2.8
* Once named KeelUDPServer.
*/
public class KeelUDPTransceiver {
private final int port;
private final DatagramSocket udpServer;
/**
* @since 3.2.0
*/
private @Nonnull KeelIssueRecorder issueRecorder;
private BiConsumer datagramSocketConsumer = (sender, buffer) -> {
// do nothing
};
public KeelUDPTransceiver(DatagramSocket udpServer, int port, @Nonnull KeelIssueRecorder issueRecorder) {
this.port = port;
this.udpServer = udpServer;
this.setIssueRecorder(issueRecorder);
}
/**
* @since 3.2.0
*/
public @Nonnull KeelIssueRecorder getIssueRecorder() {
return issueRecorder;
}
/**
* @since 3.2.0
*/
public KeelUDPTransceiver setIssueRecorder(KeelIssueRecorder issueRecorder) {
this.issueRecorder = issueRecorder;
this.issueRecorder.setRecordFormatter(r -> r.classification("port:" + port));
return this;
}
public KeelUDPTransceiver setDatagramSocketConsumer(BiConsumer datagramSocketConsumer) {
Objects.requireNonNull(datagramSocketConsumer);
this.datagramSocketConsumer = datagramSocketConsumer;
return this;
}
public Future
© 2015 - 2024 Weber Informatics LLC | Privacy Policy