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.Channel
protected 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 TypeMethodDescriptionvoid
close()
Stops the component.protected void
failed()
CallonFailure
if the client can permanently not establish a connection anymore.protected org.slf4j.Logger
protected static ClientChannelInitializer
initiateChannelInitializer
(ClientEnvironment environment, Class<? extends io.netty.channel.ChannelInitializer<io.netty.channel.socket.SocketChannel>> clazz) void
open()
Starts the component.protected boolean
Should 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()CallonFailure
if the client can permanently not establish a connection anymore. -
getLogger
protected org.slf4j.Logger getLogger() -
open
public void open()Description copied from interface:DrasylNodeComponent
Starts the component.- Specified by:
open
in interfaceDrasylNodeComponent
-
close
public void close()Description copied from interface:DrasylNodeComponent
Stops the component.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceDrasylNodeComponent
-
initiateChannelInitializer
protected static ClientChannelInitializer initiateChannelInitializer(ClientEnvironment environment, Class<? extends io.netty.channel.ChannelInitializer<io.netty.channel.socket.SocketChannel>> clazz) throws ClientException - Throws:
ClientException
-