Class DirectClient
- java.lang.Object
-
- org.drasyl.peer.connection.client.DirectClient
-
- All Implemented Interfaces:
AutoCloseable
,DrasylNodeComponent
public class DirectClient extends Object
Used byDirectConnectionsManager
to establish a direct connection to another peer.
-
-
Field Summary
Fields Modifier and Type Field Description protected BooleanSupplier
acceptNewConnectionsSupplier
protected io.netty.channel.Channel
channel
-
Constructor Summary
Constructors Constructor Description DirectClient(DrasylConfig config, Identity identity, PeersManager peersManager, Messenger messenger, PeerChannelGroup channelGroup, io.netty.channel.EventLoopGroup workerGroup, Consumer<Event> eventConsumer, Supplier<Set<Endpoint>> endpointsSupplier, BooleanSupplier directConnectionDemand, Runnable onFailure, BooleanSupplier acceptNewConnectionsSupplier)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Stops the component.protected void
failed()
CallonFailure
if the client can permanently not establish a connection anymore.protected org.slf4j.Logger
getLogger()
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
shouldRetry()
Should only make a new connection attempt if there is still a demand for it.
-
-
-
Field Detail
-
channel
protected io.netty.channel.Channel channel
-
acceptNewConnectionsSupplier
protected BooleanSupplier acceptNewConnectionsSupplier
-
-
Constructor Detail
-
DirectClient
public DirectClient(DrasylConfig config, Identity identity, PeersManager peersManager, Messenger messenger, PeerChannelGroup channelGroup, io.netty.channel.EventLoopGroup workerGroup, Consumer<Event> eventConsumer, Supplier<Set<Endpoint>> endpointsSupplier, BooleanSupplier directConnectionDemand, Runnable onFailure, BooleanSupplier acceptNewConnectionsSupplier)
-
-
Method Detail
-
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
-
-