Class WebSocketHandler
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelInboundHandlerAdapter
-
- io.netty.channel.SimpleChannelInboundHandler<java.lang.Object>
-
- org.openmuc.jeebus.ship.node.websocket.WebSocketHandler
-
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler,AuthenticatedConnection,BasicConnection
- Direct Known Subclasses:
ShipClientHandler,ShipServerHandler
public abstract class WebSocketHandler extends io.netty.channel.SimpleChannelInboundHandler<java.lang.Object> implements AuthenticatedConnection
-
-
Field Summary
Fields Modifier and Type Field Description protected io.netty.channel.Channelchannelprotected ShipConnectionImplconnectionprotected org.slf4j.Loggerlogprotected java.io.ByteArrayOutputStreammessageBufferprotected ShipNodeImplnodeprotected ShipNodeContextnodeContextprotected booleanpongReceivedprotected java.util.concurrent.CountDownLatchshipConnRdyLatch
-
Constructor Summary
Constructors Modifier Constructor Description protectedWebSocketHandler(ShipNodeContext nodeContext, ShipNodeImpl node)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidclose()protected voiddoubleConnProcedure(java.lang.String peerSki)voidexceptionCaught(io.netty.channel.ChannelHandlerContext ctx, java.lang.Throwable cause)java.lang.StringgetPeerSki()java.lang.StringgetRemoteAddress()java.lang.StringgetRemoteHost()java.lang.StringgetRemoteIpAndPort()ShipConnectionImplgetShipConnection()intgetTrustLevel()protected voidhandlePingPongFrame(io.netty.handler.codec.http.websocketx.WebSocketFrame frame)protected byte[]handleWebSocketFrame(io.netty.handler.codec.http.websocketx.WebSocketFrame frame)protected booleanisPingPongFrame(io.netty.handler.codec.http.websocketx.WebSocketFrame frame)booleanisShipConnRdy(int timeoutSeconds)voidsendMsg(byte[] msg)-
Methods inherited from class io.netty.channel.SimpleChannelInboundHandler
acceptInboundMessage, channelRead, channelRead0
-
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggered
-
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharable
-
-
-
-
Field Detail
-
log
protected final org.slf4j.Logger log
-
node
protected final ShipNodeImpl node
-
nodeContext
protected ShipNodeContext nodeContext
-
connection
protected ShipConnectionImpl connection
-
channel
protected io.netty.channel.Channel channel
-
shipConnRdyLatch
protected java.util.concurrent.CountDownLatch shipConnRdyLatch
-
pongReceived
protected boolean pongReceived
-
messageBuffer
protected final java.io.ByteArrayOutputStream messageBuffer
-
-
Constructor Detail
-
WebSocketHandler
protected WebSocketHandler(ShipNodeContext nodeContext, ShipNodeImpl node)
-
-
Method Detail
-
sendMsg
public void sendMsg(byte[] msg)
- Specified by:
sendMsgin interfaceBasicConnection
-
isPingPongFrame
protected boolean isPingPongFrame(io.netty.handler.codec.http.websocketx.WebSocketFrame frame)
-
handlePingPongFrame
protected void handlePingPongFrame(io.netty.handler.codec.http.websocketx.WebSocketFrame frame)
-
handleWebSocketFrame
protected byte[] handleWebSocketFrame(io.netty.handler.codec.http.websocketx.WebSocketFrame frame)
-
getTrustLevel
public int getTrustLevel()
-
getPeerSki
public java.lang.String getPeerSki()
- Specified by:
getPeerSkiin interfaceAuthenticatedConnection
-
getRemoteAddress
public java.lang.String getRemoteAddress()
- Specified by:
getRemoteAddressin interfaceAuthenticatedConnection
-
getRemoteIpAndPort
public java.lang.String getRemoteIpAndPort()
-
getRemoteHost
public java.lang.String getRemoteHost()
-
doubleConnProcedure
protected void doubleConnProcedure(java.lang.String peerSki)
-
isShipConnRdy
public boolean isShipConnRdy(int timeoutSeconds) throws java.lang.InterruptedException- Throws:
java.lang.InterruptedException
-
getShipConnection
public ShipConnectionImpl getShipConnection()
-
close
public abstract void close()
- Specified by:
closein interfaceBasicConnection
-
exceptionCaught
public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, java.lang.Throwable cause) throws java.lang.Exception- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelHandler- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
exceptionCaughtin classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
java.lang.Exception
-
-