Class SuperPeerClient
- java.lang.Object
-
- org.drasyl.peer.connection.client.SuperPeerClient
-
- All Implemented Interfaces:
AutoCloseable
,DrasylNodeComponent
public class SuperPeerClient extends Object
This class represents the link betweenDrasylNode
and the super peer. It is responsible for maintaining the connection to the super peer and updates the data of the super peer inPeersManager
.
-
-
Field Summary
Fields Modifier and Type Field Description protected BooleanSupplier
acceptNewConnectionsSupplier
protected io.netty.channel.Channel
channel
-
Constructor Summary
Constructors Modifier Constructor Description protected
SuperPeerClient(DrasylConfig config, io.netty.channel.EventLoopGroup workerGroup, BooleanSupplier acceptNewConnectionsSupplier, DrasylFunction<Endpoint,io.netty.bootstrap.Bootstrap,ClientException> bootstrapSupplier)
SuperPeerClient(DrasylConfig config, Identity identity, PeersManager peersManager, Messenger messenger, PeerChannelGroup channelGroup, io.netty.channel.EventLoopGroup workerGroup, Consumer<Event> eventConsumer, 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()
This method is called if a connection was not possible and no further connection attempts will be made.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()
-
-
-
Field Detail
-
channel
protected io.netty.channel.Channel channel
-
acceptNewConnectionsSupplier
protected BooleanSupplier acceptNewConnectionsSupplier
-
-
Constructor Detail
-
SuperPeerClient
protected SuperPeerClient(DrasylConfig config, io.netty.channel.EventLoopGroup workerGroup, BooleanSupplier acceptNewConnectionsSupplier, DrasylFunction<Endpoint,io.netty.bootstrap.Bootstrap,ClientException> bootstrapSupplier)
-
SuperPeerClient
public SuperPeerClient(DrasylConfig config, Identity identity, PeersManager peersManager, Messenger messenger, PeerChannelGroup channelGroup, io.netty.channel.EventLoopGroup workerGroup, Consumer<Event> eventConsumer, BooleanSupplier acceptNewConnectionsSupplier)
-
-
Method Detail
-
getLogger
protected org.slf4j.Logger getLogger()
-
open
public void open()
Description copied from interface:DrasylNodeComponent
Starts the component.- Specified by:
open
in interfaceDrasylNodeComponent
-
shouldRetry
protected boolean shouldRetry()
- Returns:
true
if the client should attempt to reconnect. Otherwisefalse
is returned
-
failed
protected void failed()
This method is called if a connection was not possible and no further connection attempts will be made.
-
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
-
-