Search in sources :

Example 16 with Connection

use of reactor.netty.Connection in project reactor-netty by reactor.

the class Application method main.

public static void main(String[] args) {
    Connection connection = UdpClient.create().host("example.com").port(80).doOnConnected(// <1>
    conn -> conn.addHandler(new LineBasedFrameDecoder(8192))).doOnChannelInit((observer, channel, remoteAddress) -> channel.pipeline().addFirst(// <2>
    new LoggingHandler("reactor.netty.examples"))).connectNow(Duration.ofSeconds(30));
    connection.onDispose().block();
}
Also used : LineBasedFrameDecoder(io.netty.handler.codec.LineBasedFrameDecoder) LoggingHandler(io.netty.handler.logging.LoggingHandler) UdpClient(reactor.netty.udp.UdpClient) Duration(java.time.Duration) Connection(reactor.netty.Connection) LoggingHandler(io.netty.handler.logging.LoggingHandler) Connection(reactor.netty.Connection) LineBasedFrameDecoder(io.netty.handler.codec.LineBasedFrameDecoder)

Example 17 with Connection

use of reactor.netty.Connection in project reactor-netty by reactor.

the class Application method main.

public static void main(String[] args) {
    Connection connection = UdpClient.create().host("example.com").port(80).metrics(true, // <1>
    CustomChannelMetricsRecorder::new).connectNow(Duration.ofSeconds(30));
    connection.onDispose().block();
}
Also used : Connection(reactor.netty.Connection)

Example 18 with Connection

use of reactor.netty.Connection in project reactor-netty by reactor.

the class Application method main.

public static void main(String[] args) {
    UdpClient udpClient = UdpClient.create().host("example.com").port(80).handle((udpInbound, udpOutbound) -> udpOutbound.sendString(Mono.just("hello")));
    // <1>
    udpClient.warmup().block();
    // <2>
    Connection connection = udpClient.connectNow(Duration.ofSeconds(30));
    connection.onDispose().block();
}
Also used : Connection(reactor.netty.Connection) UdpClient(reactor.netty.udp.UdpClient)

Example 19 with Connection

use of reactor.netty.Connection in project reactor-netty by reactor.

the class Application method main.

public static void main(String[] args) {
    Connection connection = UdpClient.create().host("example.com").port(80).wiretap("logger-name", LogLevel.DEBUG, // <1>
    AdvancedByteBufFormat.TEXTUAL).connectNow(Duration.ofSeconds(30));
    connection.onDispose().block();
}
Also used : Connection(reactor.netty.Connection)

Example 20 with Connection

use of reactor.netty.Connection in project reactor-netty by reactor.

the class Application method main.

public static void main(String[] args) {
    Connection connection = UdpClient.create().host("example.com").port(80).wiretap(// <1>
    true).connectNow(Duration.ofSeconds(30));
    connection.onDispose().block();
}
Also used : Connection(reactor.netty.Connection)

Aggregations

Connection (reactor.netty.Connection)137 Test (org.junit.jupiter.api.Test)69 CountDownLatch (java.util.concurrent.CountDownLatch)52 Duration (java.time.Duration)49 Mono (reactor.core.publisher.Mono)47 InetSocketAddress (java.net.InetSocketAddress)41 TimeUnit (java.util.concurrent.TimeUnit)39 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)38 LoopResources (reactor.netty.resources.LoopResources)38 ByteBuf (io.netty.buffer.ByteBuf)35 Flux (reactor.core.publisher.Flux)35 DisposableServer (reactor.netty.DisposableServer)35 DomainSocketAddress (io.netty.channel.unix.DomainSocketAddress)33 AtomicReference (java.util.concurrent.atomic.AtomicReference)32 List (java.util.List)31 IOException (java.io.IOException)30 Assertions.assertThatExceptionOfType (org.assertj.core.api.Assertions.assertThatExceptionOfType)30 ChannelOption (io.netty.channel.ChannelOption)29 Unpooled (io.netty.buffer.Unpooled)28 Charset (java.nio.charset.Charset)28