Class Server
- java.lang.Object
-
- org.drasyl.peer.connection.server.Server
-
- All Implemented Interfaces:
AutoCloseable
public class Server extends Object implements AutoCloseable
The server binds to a defined port and thus allows the node to be discovered and contacted by other peers.
-
-
Field Summary
Fields Modifier and Type Field Description io.netty.channel.EventLoopGroup
bossGroup
protected ServerChannelGroup
channelGroup
protected io.netty.channel.ChannelInitializer<io.netty.channel.socket.SocketChannel>
channelInitializer
io.netty.bootstrap.ServerBootstrap
serverBootstrap
io.netty.channel.EventLoopGroup
workerGroup
-
Constructor Summary
Constructors Constructor Description Server(Supplier<Identity> identitySupplier, Messenger messenger, PeersManager peersManager, DrasylConfig config, io.netty.channel.EventLoopGroup workerGroup, io.netty.channel.EventLoopGroup bossGroup, io.reactivex.rxjava3.core.Observable<Boolean> superPeerConnected, AtomicBoolean opened, Consumer<CompressedPublicKey> peerCommunicationConsumer)
Node server for forwarding messages to child peers.Server(Supplier<Identity> identitySupplier, Messenger messenger, PeersManager peersManager, DrasylConfig config, io.netty.channel.EventLoopGroup workerGroup, io.netty.channel.EventLoopGroup bossGroup, io.reactivex.rxjava3.core.Observable<Boolean> superPeerConnected, Consumer<CompressedPublicKey> peerCommunicationConsumer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the server socket and all open client sockets.Set<URI>
getEndpoints()
int
getPort()
Returns the actual bind port used by this server.boolean
isOpen()
void
open()
Starts the relay server.
-
-
-
Field Detail
-
workerGroup
public final io.netty.channel.EventLoopGroup workerGroup
-
bossGroup
public final io.netty.channel.EventLoopGroup bossGroup
-
serverBootstrap
public final io.netty.bootstrap.ServerBootstrap serverBootstrap
-
channelGroup
protected final ServerChannelGroup channelGroup
-
channelInitializer
protected final io.netty.channel.ChannelInitializer<io.netty.channel.socket.SocketChannel> channelInitializer
-
-
Constructor Detail
-
Server
public Server(Supplier<Identity> identitySupplier, Messenger messenger, PeersManager peersManager, DrasylConfig config, io.netty.channel.EventLoopGroup workerGroup, io.netty.channel.EventLoopGroup bossGroup, io.reactivex.rxjava3.core.Observable<Boolean> superPeerConnected, Consumer<CompressedPublicKey> peerCommunicationConsumer) throws ServerException
- Throws:
ServerException
-
Server
public Server(Supplier<Identity> identitySupplier, Messenger messenger, PeersManager peersManager, DrasylConfig config, io.netty.channel.EventLoopGroup workerGroup, io.netty.channel.EventLoopGroup bossGroup, io.reactivex.rxjava3.core.Observable<Boolean> superPeerConnected, AtomicBoolean opened, Consumer<CompressedPublicKey> peerCommunicationConsumer) throws ServerException
Node server for forwarding messages to child peers.- Parameters:
identitySupplier
- the identity managermessenger
- the messenger objectpeersManager
- the peers managerconfig
- config that should be usedworkerGroup
- netty shared worker groupbossGroup
- netty shared boss groupsuperPeerConnected
-peerCommunicationConsumer
-- Throws:
ServerException
-
-
Method Detail
-
isOpen
public boolean isOpen()
-
open
public void open() throws ServerException
Starts the relay server.- Throws:
ServerException
-
getPort
public int getPort()
Returns the actual bind port used by this server.
-
close
public void close()
Closes the server socket and all open client sockets.- Specified by:
close
in interfaceAutoCloseable
-
-