Class ThreeWayHandshakeClientHandler<R extends RequestMessage,O extends ResponseMessage<?>> 
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.SimpleChannelInboundHandler<I>
org.drasyl.peer.connection.handler.SimpleChannelDuplexHandler<Message,Message>
 
org.drasyl.peer.connection.handler.ThreeWayHandshakeClientHandler<R,O> 
- All Implemented Interfaces:
 io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler,io.netty.channel.ChannelOutboundHandler
- Direct Known Subclasses:
 ClientConnectionHandler
public abstract class ThreeWayHandshakeClientHandler<R extends RequestMessage,O extends ResponseMessage<?>> 
extends SimpleChannelDuplexHandler<Message,Message> 
This handler performs the client-side part of a three-way handshake to create a session. It
 automatically requests the server for a new session. The server must confirm this request and
 then offers the client a session. Then the client has to confirm the offered session again.
- 
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable - 
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final io.netty.util.AttributeKey<CompressedPublicKey>protected final CompletableFuture<Void>protected final Identityprotected final intprotected final Pipelineprotected final Durationprotected io.netty.util.concurrent.ScheduledFuture<?> - 
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedThreeWayHandshakeClientHandler(int networkId, Identity identity, Duration timeout, Pipeline pipeline, CompletableFuture<Void> handshakeFuture, io.netty.util.concurrent.ScheduledFuture<?> timeoutFuture, R requestMessage) protectedThreeWayHandshakeClientHandler(int networkId, Identity identity, Duration timeout, Pipeline pipeline, R requestMessage)  - 
Method Summary
Modifier and TypeMethodDescriptionvoidchannelActive(io.netty.channel.ChannelHandlerContext ctx) voidchannelRead0(io.netty.channel.ChannelHandlerContext ctx, Message msg) Is called for each message of typeSimpleChannelDuplexHandleron inbound channel.protected voidchannelWrite0(io.netty.channel.ChannelHandlerContext ctx, Message msg, io.netty.channel.ChannelPromise promise) Is called for each message of typeSimpleChannelDuplexHandleron the outbound channel.voidclose(io.netty.channel.ChannelHandlerContext ctx, io.netty.channel.ChannelPromise promise) protected voidconfirmSession(io.netty.channel.ChannelHandlerContext ctx, O offerMessage) protected abstract voidcreateConnection(io.netty.channel.ChannelHandlerContext ctx, O offerMessage) protected voiddoHandshake(io.netty.channel.ChannelHandlerContext ctx, Message message) voidexceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) protected abstract org.slf4j.LoggervoidhandlerAdded(io.netty.channel.ChannelHandlerContext ctx) protected voidprocessMessageAfterHandshake(io.netty.channel.ChannelHandlerContext ctx, Message message) protected voidprocessUnexpectedMessageDuringHandshake(io.netty.channel.ChannelHandlerContext ctx, Message message) protected voidrejectSession(io.netty.channel.ChannelHandlerContext ctx, String error) protected voidrequestSession(io.netty.channel.ChannelHandlerContext ctx) protected voidstartTimeoutGuard(io.netty.channel.ChannelHandlerContext ctx) protected abstract ErrorMessage.ErrorvalidateSessionOffer(O offerMessage) This method validates the session offered by the server and must return anErrorMessage.Errorin case of error.Methods inherited from class org.drasyl.peer.connection.handler.SimpleChannelDuplexHandler
acceptOutboundMessage, bind, connect, deregister, disconnect, flush, read, writeMethods inherited from class io.netty.channel.SimpleChannelInboundHandler
acceptInboundMessage, channelReadMethods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggeredMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerRemoved, isSharableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.netty.channel.ChannelHandler
handlerRemoved 
- 
Field Details
- 
ATTRIBUTE_PUBLIC_KEY
 - 
timeout
 - 
handshakeFuture
 - 
pipeline
 - 
networkId
protected final int networkId - 
identity
 - 
timeoutFuture
protected io.netty.util.concurrent.ScheduledFuture<?> timeoutFuture 
 - 
 - 
Constructor Details
- 
ThreeWayHandshakeClientHandler
 - 
ThreeWayHandshakeClientHandler
 
 - 
 - 
Method Details
- 
doHandshake
 - 
handlerAdded
- Specified by:
 handlerAddedin interfaceio.netty.channel.ChannelHandler- Overrides:
 handlerAddedin classio.netty.channel.ChannelHandlerAdapter- Throws:
 Exception
 - 
requestSession
protected void requestSession(io.netty.channel.ChannelHandlerContext ctx)  - 
validateSessionOffer
This method validates the session offered by the server and must return anErrorMessage.Errorin case of error. Otherwisenullmust be returned.- Parameters:
 offerMessage- the message that should be validated- Returns:
 ErrorMessage.Errorin case of error, otherwisenull
 - 
confirmSession
 - 
createConnection
protected abstract void createConnection(io.netty.channel.ChannelHandlerContext ctx, O offerMessage)  - 
processUnexpectedMessageDuringHandshake
protected void processUnexpectedMessageDuringHandshake(io.netty.channel.ChannelHandlerContext ctx, Message message)  - 
getLogger
protected abstract org.slf4j.Logger getLogger() - 
channelRead0
Description copied from class:SimpleChannelDuplexHandlerIs called for each message of typeSimpleChannelDuplexHandleron inbound channel.- Specified by:
 channelRead0in classSimpleChannelDuplexHandler<Message,Message> - Parameters:
 ctx- theChannelHandlerContextwhich thisSimpleChannelDuplexHandlerbelongs tomsg- the message to handle
 - 
close
public void close(io.netty.channel.ChannelHandlerContext ctx, io.netty.channel.ChannelPromise promise) throws Exception - Specified by:
 closein interfaceio.netty.channel.ChannelOutboundHandler- Overrides:
 closein classSimpleChannelDuplexHandler<Message,Message> - Throws:
 Exception
 - 
channelWrite0
protected void channelWrite0(io.netty.channel.ChannelHandlerContext ctx, Message msg, io.netty.channel.ChannelPromise promise) Description copied from class:SimpleChannelDuplexHandlerIs called for each message of typeSimpleChannelDuplexHandleron the outbound channel.- Specified by:
 channelWrite0in classSimpleChannelDuplexHandler<Message,Message> - Parameters:
 ctx- theChannelHandlerContextwhich thisSimpleChannelDuplexHandlerbelongs tomsg- the message to handlepromise- the corresponding promise
 - 
processMessageAfterHandshake
protected void processMessageAfterHandshake(io.netty.channel.ChannelHandlerContext ctx, Message message)  - 
channelActive
- Specified by:
 channelActivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
 channelActivein classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
 Exception
 - 
startTimeoutGuard
protected void startTimeoutGuard(io.netty.channel.ChannelHandlerContext ctx)  - 
rejectSession
 - 
exceptionCaught
- Specified by:
 exceptionCaughtin interfaceio.netty.channel.ChannelHandler- Specified by:
 exceptionCaughtin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
 exceptionCaughtin classio.netty.channel.ChannelInboundHandlerAdapter
 
 -