use of reactor.netty.udp.UdpServer in project reactor-netty by reactor.
the class Application method main.
public static void main(String[] args) {
UdpServer udpServer = UdpServer.create().handle((in, out) -> out.sendObject(in.receiveObject().map(o -> {
if (o instanceof DatagramPacket) {
DatagramPacket p = (DatagramPacket) o;
return new DatagramPacket(p.content().retain(), p.sender());
} else {
return Mono.error(new Exception("Unexpected type of the message: " + o));
}
})));
// <1>
udpServer.warmup().block();
Connection server = udpServer.bindNow(Duration.ofSeconds(30));
server.onDispose().block();
}
Aggregations