Class DirectClient
java.lang.Object
org.drasyl.peer.connection.client.DirectClient
- All Implemented Interfaces:
AutoCloseable,DrasylNodeComponent
Used by
DirectConnectionsManager to establish a direct
connection to another peer.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected io.netty.channel.Channelprotected final BooleanSupplier -
Constructor Summary
ConstructorsConstructorDescriptionDirectClient(DrasylConfig config, Identity identity, PeersManager peersManager, Pipeline pipeline, PeerChannelGroup channelGroup, io.netty.channel.EventLoopGroup workerGroup, Supplier<Set<Endpoint>> endpointsSupplier, BooleanSupplier directConnectionDemand, Runnable onFailure, BooleanSupplier doNewConnectionsSupplier) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Stops the component.protected voidfailed()CallonFailureif the client can permanently not establish a connection anymore.protected org.slf4j.Loggerprotected static ClientChannelInitializerinitiateChannelInitializer(ClientEnvironment environment, Class<? extends io.netty.channel.ChannelInitializer<io.netty.channel.socket.SocketChannel>> clazz) voidopen()Starts the component.protected booleanShould only make a new connection attempt if there is still a demand for it.
-
Field Details
-
doNewConnectionsSupplier
-
channel
protected io.netty.channel.Channel channel
-
-
Constructor Details
-
DirectClient
public DirectClient(DrasylConfig config, Identity identity, PeersManager peersManager, Pipeline pipeline, PeerChannelGroup channelGroup, io.netty.channel.EventLoopGroup workerGroup, Supplier<Set<Endpoint>> endpointsSupplier, BooleanSupplier directConnectionDemand, Runnable onFailure, BooleanSupplier doNewConnectionsSupplier)
-
-
Method Details
-
shouldRetry
protected boolean shouldRetry()Should only make a new connection attempt if there is still a demand for it.- Returns:
- if a retry should be made
-
failed
protected void failed()CallonFailureif the client can permanently not establish a connection anymore. -
getLogger
protected org.slf4j.Logger getLogger() -
open
public void open()Description copied from interface:DrasylNodeComponentStarts the component.- Specified by:
openin interfaceDrasylNodeComponent
-
close
public void close()Description copied from interface:DrasylNodeComponentStops the component.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceDrasylNodeComponent
-
initiateChannelInitializer
protected static ClientChannelInitializer initiateChannelInitializer(ClientEnvironment environment, Class<? extends io.netty.channel.ChannelInitializer<io.netty.channel.socket.SocketChannel>> clazz) throws ClientException - Throws:
ClientException
-