Package org.drasyl.peer.connection
Class DefaultSessionInitializer
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.ChannelInitializer<io.netty.channel.socket.SocketChannel>
org.drasyl.peer.connection.DefaultSessionInitializer
- All Implemented Interfaces:
io.netty.channel.ChannelHandler
,io.netty.channel.ChannelInboundHandler
- Direct Known Subclasses:
ClientChannelInitializer
,ServerChannelInitializer
public abstract class DefaultSessionInitializer
extends io.netty.channel.ChannelInitializer<io.netty.channel.socket.SocketChannel>
Creates a newly configured
ChannelPipeline
for a new channel for a connection to or from
a the Server
.
Note: You have to add a websocket handler by yourself to the beforeMarshalStage(ChannelPipeline)
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
DefaultSessionInitializer
(int networkId, Identity identity, int flushBufferSize, Duration readIdleTimeout, short pingPongRetries) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
afterBufferStage
(io.netty.channel.ChannelPipeline pipeline) protected void
afterExceptionStage
(io.netty.channel.ChannelPipeline pipeline) protected void
afterFilterStage
(io.netty.channel.ChannelPipeline pipeline) protected void
afterIdleStage
(io.netty.channel.ChannelPipeline pipeline) protected void
afterMarshalStage
(io.netty.channel.ChannelPipeline pipeline) protected void
afterPojoMarshalStage
(io.netty.channel.ChannelPipeline pipeline) protected void
afterSslStage
(io.netty.channel.socket.SocketChannel ch) protected void
beforeBufferStage
(io.netty.channel.ChannelPipeline pipeline) protected void
beforeExceptionStage
(io.netty.channel.ChannelPipeline pipeline) protected void
beforeFilterStage
(io.netty.channel.ChannelPipeline pipeline) protected void
beforeIdleStage
(io.netty.channel.ChannelPipeline pipeline) protected abstract void
beforeMarshalStage
(io.netty.channel.ChannelPipeline pipeline) protected void
beforePojoMarshalStage
(io.netty.channel.ChannelPipeline pipeline) protected void
beforeSslStage
(io.netty.channel.socket.SocketChannel ch) protected void
bufferStage
(io.netty.channel.ChannelPipeline pipeline) AddsChannelHandler
for buffer strategies to theChannelPipeline
.protected abstract void
customStage
(io.netty.channel.ChannelPipeline pipeline) AddsChannelHandler
to theChannelPipeline
, after the default initialization has taken place.protected void
exceptionStage
(io.netty.channel.ChannelPipeline pipeline) AddsChannelHandler
for exception handling to theChannelPipeline
.protected void
filterStage
(io.netty.channel.ChannelPipeline pipeline) AddsChannelHandler
for filtering to theChannelPipeline
.protected abstract io.netty.handler.ssl.SslHandler
generateSslContext
(io.netty.channel.socket.SocketChannel ch) Generates aSslHandler
that can be added to theChannelPipeline
.protected void
idleStage
(io.netty.channel.ChannelPipeline pipeline) AddsChannelHandler
for idle handling to theChannelPipeline
.protected void
initChannel
(io.netty.channel.socket.SocketChannel ch) protected void
marshalStage
(io.netty.channel.ChannelPipeline pipeline) AddsChannelHandler
for marshalling to theChannelPipeline
.protected void
pojoMarshalStage
(io.netty.channel.ChannelPipeline pipeline) AddsChannelHandler
for POJO marshalling handling to theChannelPipeline
.protected void
sslStage
(io.netty.channel.socket.SocketChannel ch) At this stage theSslHandler
is added to the pipeline.Methods inherited from class io.netty.channel.ChannelInitializer
channelRegistered, exceptionCaught, handlerAdded, handlerRemoved
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelInactive, channelRead, channelReadComplete, channelUnregistered, channelWritabilityChanged, userEventTriggered
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, isSharable
-
Field Details
-
IDLE_EVENT
- See Also:
-
-
Constructor Details
-
DefaultSessionInitializer
-
-
Method Details
-
initChannel
- Specified by:
initChannel
in classio.netty.channel.ChannelInitializer<io.netty.channel.socket.SocketChannel>
- Throws:
DrasylException
-
beforeSslStage
protected void beforeSslStage(io.netty.channel.socket.SocketChannel ch) -
sslStage
At this stage theSslHandler
is added to the pipeline.- Parameters:
ch
- theSocketChannel
- Throws:
DrasylException
-
afterSslStage
protected void afterSslStage(io.netty.channel.socket.SocketChannel ch) -
beforeBufferStage
protected void beforeBufferStage(io.netty.channel.ChannelPipeline pipeline) -
bufferStage
protected void bufferStage(io.netty.channel.ChannelPipeline pipeline) AddsChannelHandler
for buffer strategies to theChannelPipeline
.- Parameters:
pipeline
- theChannelPipeline
-
afterBufferStage
protected void afterBufferStage(io.netty.channel.ChannelPipeline pipeline) -
beforeMarshalStage
protected abstract void beforeMarshalStage(io.netty.channel.ChannelPipeline pipeline) -
marshalStage
protected void marshalStage(io.netty.channel.ChannelPipeline pipeline) AddsChannelHandler
for marshalling to theChannelPipeline
.- Parameters:
pipeline
- theChannelPipeline
-
afterMarshalStage
protected void afterMarshalStage(io.netty.channel.ChannelPipeline pipeline) -
beforeFilterStage
protected void beforeFilterStage(io.netty.channel.ChannelPipeline pipeline) -
filterStage
protected void filterStage(io.netty.channel.ChannelPipeline pipeline) AddsChannelHandler
for filtering to theChannelPipeline
.- Parameters:
pipeline
- theChannelPipeline
-
afterFilterStage
protected void afterFilterStage(io.netty.channel.ChannelPipeline pipeline) -
beforePojoMarshalStage
protected void beforePojoMarshalStage(io.netty.channel.ChannelPipeline pipeline) -
pojoMarshalStage
protected void pojoMarshalStage(io.netty.channel.ChannelPipeline pipeline) AddsChannelHandler
for POJO marshalling handling to theChannelPipeline
.- Parameters:
pipeline
- theChannelPipeline
-
afterPojoMarshalStage
protected void afterPojoMarshalStage(io.netty.channel.ChannelPipeline pipeline) -
beforeIdleStage
protected void beforeIdleStage(io.netty.channel.ChannelPipeline pipeline) -
idleStage
protected void idleStage(io.netty.channel.ChannelPipeline pipeline) AddsChannelHandler
for idle handling to theChannelPipeline
.- Parameters:
pipeline
- theChannelPipeline
-
afterIdleStage
protected void afterIdleStage(io.netty.channel.ChannelPipeline pipeline) -
customStage
protected abstract void customStage(io.netty.channel.ChannelPipeline pipeline) AddsChannelHandler
to theChannelPipeline
, after the default initialization has taken place.- Parameters:
pipeline
- theChannelPipeline
-
beforeExceptionStage
protected void beforeExceptionStage(io.netty.channel.ChannelPipeline pipeline) -
exceptionStage
protected void exceptionStage(io.netty.channel.ChannelPipeline pipeline) AddsChannelHandler
for exception handling to theChannelPipeline
.- Parameters:
pipeline
- theChannelPipeline
-
afterExceptionStage
protected void afterExceptionStage(io.netty.channel.ChannelPipeline pipeline) - Parameters:
pipeline
- theChannelPipeline
-
generateSslContext
protected abstract io.netty.handler.ssl.SslHandler generateSslContext(io.netty.channel.socket.SocketChannel ch) throws DrasylException Generates aSslHandler
that can be added to theChannelPipeline
. If this method returnsnull
, the SslHandler is not added to theChannelPipeline
.- Parameters:
ch
- theSocketChannel
to initialize aSslHandler
- Returns:
SslHandler
ornull
- Throws:
DrasylException
-