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 configuredChannelPipeline
for a new channel for a connection to or from a theServer
.Note: You have to add a websocket handler by yourself to the
beforeMarshalStage(ChannelPipeline)
-
-
Field Summary
Fields Modifier and Type Field Description static String
IDLE_EVENT
-
Constructor Summary
Constructors Modifier Constructor Description protected
DefaultSessionInitializer(int networkId, Identity identity, int flushBufferSize, Duration readIdleTimeout, short pingPongRetries)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected 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
-
-
-
-
Field Detail
-
IDLE_EVENT
public static final String IDLE_EVENT
- See Also:
- Constant Field Values
-
-
Method Detail
-
initChannel
protected void initChannel(io.netty.channel.socket.SocketChannel ch) throws DrasylException
- 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
protected void sslStage(io.netty.channel.socket.SocketChannel ch) throws DrasylException
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
-
-