Package rocks.xmpp.nio.netty.client
Class NettyChannelConnector
- java.lang.Object
-
- rocks.xmpp.core.net.client.AbstractTcpConnector<io.netty.channel.Channel>
-
- rocks.xmpp.nio.netty.client.NettyChannelConnector
-
- All Implemented Interfaces:
TransportConnector<TcpConnectionConfiguration>
public final class NettyChannelConnector extends AbstractTcpConnector<io.netty.channel.Channel>
A TCP transport connector which uses theChannel
.Unlike
SocketConnector
, this connector is NIO based and therefore does not use blocking IO and therefore less threads.Sample Usage
TcpConnectionConfiguration tcpConfiguration = TcpConnectionConfiguration.builder() .hostname("localhost") .port(5222) .sslContext(sslContext) .channelEncryption(ChannelEncryption.REQUIRED) .connector(new NettyChannelConnector()) .build();
-
-
Constructor Summary
Constructors Constructor Description NettyChannelConnector()
Creates a connector using a defaultNioEventLoopGroup
.NettyChannelConnector(io.netty.channel.EventLoopGroup eventLoopGroup)
Creates a connector using a givenNioEventLoopGroup
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CompletableFuture<Connection>
connect(XmppSession xmppSession, TcpConnectionConfiguration configuration, SessionOpen sessionOpen)
Establishes a connection using the transport protocol specific configuration.
-
-
-
Constructor Detail
-
NettyChannelConnector
public NettyChannelConnector()
Creates a connector using a defaultNioEventLoopGroup
.
-
NettyChannelConnector
public NettyChannelConnector(io.netty.channel.EventLoopGroup eventLoopGroup)
Creates a connector using a givenNioEventLoopGroup
.- Parameters:
eventLoopGroup
- The Netty event loop group.
-
-
Method Detail
-
connect
public final CompletableFuture<Connection> connect(XmppSession xmppSession, TcpConnectionConfiguration configuration, SessionOpen sessionOpen)
Description copied from interface:TransportConnector
Establishes a connection using the transport protocol specific configuration.- Parameters:
xmppSession
- The XMPP session which will be bound to the transport protocol.configuration
- The connection configuration for the specific transport protocol.sessionOpen
- The session open element.- Returns:
- A
CompletableFuture
which returns an established (connected) connection on completion.
-
-