Package io.undertow.websockets.core
Class AbstractReceiveListener
- java.lang.Object
-
- io.undertow.websockets.core.AbstractReceiveListener
-
- All Implemented Interfaces:
EventListener,org.xnio.ChannelListener<WebSocketChannel>
public abstract class AbstractReceiveListener extends Object implements org.xnio.ChannelListener<WebSocketChannel>
A receive listener that performs a callback when it receives a message- Author:
- Stuart Douglas, baranowb
-
-
Field Summary
Fields Modifier and Type Field Description protected intcountInWindowstatic intDEFAULT_WEB_SOCKETS_CONTROL_FRAME_SIZEMaximum control frame size: https://datatracker.ietf.org/doc/html/rfc6455#section-5.5static intDEFAULT_WEB_SOCKETS_MAX_READ_FRAMESDefault value for max read frames. -1 - unbounded.static intDEFAULT_WEB_SOCKETS_MESSAGE_SIZEDefault size of data frames. -1 - unbounded.static intDEFAULT_WEB_SOCKETS_PING_MAX_PER_WINDOWDefault numbers of acceptable pings per window.static intDEFAULT_WEB_SOCKETS_PING_WINDOWDefault length of websocket ping window in milliseconds.protected intmaxCountInWindowstatic StringWEB_SOCKETS_MAX_READ_FRAMES_PROPERTYstatic StringWEB_SOCKETS_PING_MAX_PER_WINDOW_PROPERTYOption controlling max pings count during window; Defaults toUndertowOptions#DEFAULT_WEB_SOCKETS_PING_MAX_PER_WINDOWstatic StringWEB_SOCKETS_PING_WINDOW_PROPERTYOption controlling ping window duration.static StringWEB_SOCKETS_SIZE_BINARY_PROPERTYMaximum size of BINARY message.static StringWEB_SOCKETS_SIZE_TEXT_PROPERTYMaximum size of TEXT message.protected longwindowLengthprotected longwindowTStampThreshold
-
Constructor Summary
Constructors Constructor Description AbstractReceiveListener()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidbufferFullMessage(StreamSourceFrameChannel messageChannel)Utility method that reads a full text or binary message, including all fragmented parts.protected voidcountPing(WebSocketChannel channel)protected longgetMaxBinaryBufferSize()protected longgetMaxCloseBufferSize()protected longgetMaxPingBufferSize()protected intgetMaxPingsPerWindow()protected longgetMaxPongBufferSize()protected longgetMaxTextBufferSize()protected longgetPingWindowLength()REturn sliding window length in milliseconds.voidhandleEvent(WebSocketChannel channel)protected voidonBinary(WebSocketChannel webSocketChannel, StreamSourceFrameChannel messageChannel)protected voidonClose(WebSocketChannel webSocketChannel, StreamSourceFrameChannel channel)protected voidonCloseMessage(CloseMessage cm, WebSocketChannel channel)protected voidonError(WebSocketChannel channel, Throwable error)protected voidonFullBinaryMessage(WebSocketChannel channel, BufferedBinaryMessage message)protected voidonFullCloseMessage(WebSocketChannel channel, BufferedBinaryMessage message)protected voidonFullPingMessage(WebSocketChannel channel, BufferedBinaryMessage message)protected voidonFullPongMessage(WebSocketChannel channel, BufferedBinaryMessage message)protected voidonFullTextMessage(WebSocketChannel channel, BufferedTextMessage message)protected voidonPing(WebSocketChannel webSocketChannel, StreamSourceFrameChannel channel)protected voidonPong(WebSocketChannel webSocketChannel, StreamSourceFrameChannel messageChannel)protected voidonText(WebSocketChannel webSocketChannel, StreamSourceFrameChannel messageChannel)
-
-
-
Field Detail
-
WEB_SOCKETS_MAX_READ_FRAMES_PROPERTY
public static final String WEB_SOCKETS_MAX_READ_FRAMES_PROPERTY
- See Also:
- Constant Field Values
-
DEFAULT_WEB_SOCKETS_MAX_READ_FRAMES
public static final int DEFAULT_WEB_SOCKETS_MAX_READ_FRAMES
Default value for max read frames. -1 - unbounded.- See Also:
- Constant Field Values
-
DEFAULT_WEB_SOCKETS_MESSAGE_SIZE
public static final int DEFAULT_WEB_SOCKETS_MESSAGE_SIZE
Default size of data frames. -1 - unbounded. https://datatracker.ietf.org/doc/html/rfc6455#section-5.6- See Also:
- Constant Field Values
-
DEFAULT_WEB_SOCKETS_CONTROL_FRAME_SIZE
public static final int DEFAULT_WEB_SOCKETS_CONTROL_FRAME_SIZE
Maximum control frame size: https://datatracker.ietf.org/doc/html/rfc6455#section-5.5- See Also:
- Constant Field Values
-
WEB_SOCKETS_SIZE_TEXT_PROPERTY
public static final String WEB_SOCKETS_SIZE_TEXT_PROPERTY
Maximum size of TEXT message.- See Also:
- Constant Field Values
-
WEB_SOCKETS_SIZE_BINARY_PROPERTY
public static final String WEB_SOCKETS_SIZE_BINARY_PROPERTY
Maximum size of BINARY message.- See Also:
- Constant Field Values
-
DEFAULT_WEB_SOCKETS_PING_MAX_PER_WINDOW
public static final int DEFAULT_WEB_SOCKETS_PING_MAX_PER_WINDOW
Default numbers of acceptable pings per window.- See Also:
- Constant Field Values
-
WEB_SOCKETS_PING_MAX_PER_WINDOW_PROPERTY
public static final String WEB_SOCKETS_PING_MAX_PER_WINDOW_PROPERTY
Option controlling max pings count during window; Defaults toUndertowOptions#DEFAULT_WEB_SOCKETS_PING_MAX_PER_WINDOW- See Also:
- Constant Field Values
-
DEFAULT_WEB_SOCKETS_PING_WINDOW
public static final int DEFAULT_WEB_SOCKETS_PING_WINDOW
Default length of websocket ping window in milliseconds.- See Also:
- Constant Field Values
-
WEB_SOCKETS_PING_WINDOW_PROPERTY
public static final String WEB_SOCKETS_PING_WINDOW_PROPERTY
Option controlling ping window duration. Defaults toUndertowOptions#DEFAULT_WEB_SOCKETS_PING_WINDOW- See Also:
- Constant Field Values
-
windowLength
protected long windowLength
-
countInWindow
protected int countInWindow
-
maxCountInWindow
protected int maxCountInWindow
-
windowTStampThreshold
protected long windowTStampThreshold
-
-
Method Detail
-
countPing
protected void countPing(WebSocketChannel channel) throws IOException
- Throws:
IOException
-
getMaxBinaryBufferSize
protected long getMaxBinaryBufferSize()
-
getMaxPongBufferSize
protected final long getMaxPongBufferSize()
-
getMaxCloseBufferSize
protected final long getMaxCloseBufferSize()
-
getMaxPingBufferSize
protected final long getMaxPingBufferSize()
-
getMaxTextBufferSize
protected long getMaxTextBufferSize()
-
getMaxPingsPerWindow
protected int getMaxPingsPerWindow()
-
getPingWindowLength
protected long getPingWindowLength()
REturn sliding window length in milliseconds.- Returns:
-
handleEvent
public void handleEvent(WebSocketChannel channel)
- Specified by:
handleEventin interfaceorg.xnio.ChannelListener<WebSocketChannel>
-
onPing
protected void onPing(WebSocketChannel webSocketChannel, StreamSourceFrameChannel channel) throws IOException
- Throws:
IOException
-
onClose
protected void onClose(WebSocketChannel webSocketChannel, StreamSourceFrameChannel channel) throws IOException
- Throws:
IOException
-
onPong
protected void onPong(WebSocketChannel webSocketChannel, StreamSourceFrameChannel messageChannel) throws IOException
- Throws:
IOException
-
onText
protected void onText(WebSocketChannel webSocketChannel, StreamSourceFrameChannel messageChannel) throws IOException
- Throws:
IOException
-
onBinary
protected void onBinary(WebSocketChannel webSocketChannel, StreamSourceFrameChannel messageChannel) throws IOException
- Throws:
IOException
-
onError
protected void onError(WebSocketChannel channel, Throwable error)
-
bufferFullMessage
protected final void bufferFullMessage(StreamSourceFrameChannel messageChannel)
Utility method that reads a full text or binary message, including all fragmented parts. Once the full message is read then theonFullTextMessage(WebSocketChannel, BufferedTextMessage)oronFullBinaryMessage(WebSocketChannel, BufferedBinaryMessage)method will be invoked.- Parameters:
messageChannel- The message channel
-
onFullTextMessage
protected void onFullTextMessage(WebSocketChannel channel, BufferedTextMessage message) throws IOException
- Throws:
IOException
-
onFullBinaryMessage
protected void onFullBinaryMessage(WebSocketChannel channel, BufferedBinaryMessage message) throws IOException
- Throws:
IOException
-
onFullPingMessage
protected void onFullPingMessage(WebSocketChannel channel, BufferedBinaryMessage message) throws IOException
- Throws:
IOException
-
onFullPongMessage
protected void onFullPongMessage(WebSocketChannel channel, BufferedBinaryMessage message) throws IOException
- Throws:
IOException
-
onFullCloseMessage
protected void onFullCloseMessage(WebSocketChannel channel, BufferedBinaryMessage message) throws IOException
- Throws:
IOException
-
onCloseMessage
protected void onCloseMessage(CloseMessage cm, WebSocketChannel channel)
-
-