Package org.drasyl.channel
Class ConnectionChannelInitializer
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.ChannelInitializer<DrasylChannel>
org.drasyl.channel.ConnectionChannelInitializer
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler
- Direct Known Subclasses:
DrasylNodeChannelInitializer
@UnstableApi
public abstract class ConnectionChannelInitializer
extends io.netty.channel.ChannelInitializer<DrasylChannel>
This
ChannelInitializer create a channel providing reliable and ordered delivery of bytes
between hosts. Handlers can either be added to the pipeline on channel creation time using
initChannel(DrasylChannel) or after connection with the remote peer has been established
using handshakeCompleted(ChannelHandlerContext).
handshakeFailed(ChannelHandlerContext, Throwable) is called, when no connection could be
established (e.g., because the other party has not responded within the time limit or has
rejected the handshake).-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConnectionChannelInitializer(boolean doServer, int port, ConnectionConfig config) protectedConnectionChannelInitializer(int localPort, int remotePort) protectedConnectionChannelInitializer(int localPort, int remotePort, ConnectionConfig config) protectedConnectionChannelInitializer(Boolean doServer, int port) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidhandshakeCompleted(io.netty.channel.ChannelHandlerContext ctx) protected abstract voidhandshakeFailed(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) protected voidMethods inherited from class io.netty.channel.ChannelInitializer
channelRegistered, exceptionCaught, handlerAdded, handlerRemovedMethods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelInactive, channelRead, channelReadComplete, channelUnregistered, channelWritabilityChanged, userEventTriggeredMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, isSharable
-
Field Details
-
DEFAULT_SERVER_PORT
public static final int DEFAULT_SERVER_PORT- See Also:
-
config
-
-
Constructor Details
-
ConnectionChannelInitializer
-
ConnectionChannelInitializer
protected ConnectionChannelInitializer(int localPort, int remotePort) -
ConnectionChannelInitializer
- Parameters:
doServer- Determines the server behavior:
truesets this channel to server mode, listening on the specifiedport.falsesets this channel to client mode, listening on a random port while assuming the peer listens onport.
port- Specifies the port number. In server mode, the channel listens on this port. In client mode, the channel assumes the peer listens on this port.config- Configuration settings for connections.
-
ConnectionChannelInitializer
- Parameters:
doServer- Determines the server behavior:
truesets this channel to server mode, listening on the specifiedport.falsesets this channel to client mode, listening on a random port while assuming the peer listens onport.nulldecides the server/client role based on comparing local and remote public keys, with the "higher" key indicating a server.
port- Specifies the port number. In server mode, the channel listens on this port. In client mode, the channel assumes the peer listens on this port.
-
-
Method Details
-
initChannel
- Specified by:
initChannelin classio.netty.channel.ChannelInitializer<DrasylChannel>- Throws:
Exception
-
handshakeCompleted
protected abstract void handshakeCompleted(io.netty.channel.ChannelHandlerContext ctx) throws Exception - Throws:
Exception
-
handshakeFailed
protected abstract void handshakeFailed(io.netty.channel.ChannelHandlerContext ctx, Throwable cause)
-