Module io.netty5.codec.http
Class CloseWebSocketFrame
- java.lang.Object
-
- io.netty5.buffer.api.BufferHolder<WebSocketFrame>
-
- io.netty5.handler.codec.http.websocketx.WebSocketFrame
-
- io.netty5.handler.codec.http.websocketx.CloseWebSocketFrame
-
- All Implemented Interfaces:
Resource<WebSocketFrame>
,AutoCloseable
public class CloseWebSocketFrame extends WebSocketFrame
Web Socket Frame for closing the connection.
-
-
Constructor Summary
Constructors Constructor Description CloseWebSocketFrame(boolean finalFragment, int rsv, Buffer binaryData)
Creates a new close frameCloseWebSocketFrame(BufferAllocator allocator, boolean finalFragment, int rsv)
Creates a new close frame with no losing status code and no reason textCloseWebSocketFrame(BufferAllocator allocator, boolean finalFragment, int rsv, int statusCode, String reasonText)
Creates a new close frame with closing status code and reason textCloseWebSocketFrame(BufferAllocator allocator, int statusCode, String reasonText)
Creates a new empty close frame with closing status code and reason textCloseWebSocketFrame(BufferAllocator allocator, WebSocketCloseStatus status)
Creates a new empty close frame with closing status code and reason textCloseWebSocketFrame(BufferAllocator allocator, WebSocketCloseStatus status, String reasonText)
Creates a new empty close frame with closing status code and reason text
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
reasonText()
Returns the reason text as per RFC 6455 If a reason text is not supplied, an empty string is returned.protected WebSocketFrame
receive(Buffer buf)
Called when a sentBufferHolder
is received by the recipient.int
statusCode()
Returns the closing status code as per RFC 6455.-
Methods inherited from class io.netty5.handler.codec.http.websocketx.WebSocketFrame
binaryData, isFinalFragment, rsv, toString
-
Methods inherited from class io.netty5.buffer.api.BufferHolder
close, equals, getBuffer, getBufferVolatile, hashCode, isAccessible, replaceBuffer, replaceBufferVolatile, send, touch
-
-
-
-
Constructor Detail
-
CloseWebSocketFrame
public CloseWebSocketFrame(BufferAllocator allocator, WebSocketCloseStatus status)
Creates a new empty close frame with closing status code and reason text- Parameters:
allocator
-BufferAllocator
to use for allocating data.status
- Status code as per RFC 6455. For example, 1000 indicates normal closure.
-
CloseWebSocketFrame
public CloseWebSocketFrame(BufferAllocator allocator, WebSocketCloseStatus status, String reasonText)
Creates a new empty close frame with closing status code and reason text- Parameters:
allocator
-BufferAllocator
to use for allocating data.status
- Status code as per RFC 6455. For example, 1000 indicates normal closure.reasonText
- Reason text. Set to null if no text.
-
CloseWebSocketFrame
public CloseWebSocketFrame(BufferAllocator allocator, int statusCode, String reasonText)
Creates a new empty close frame with closing status code and reason text- Parameters:
allocator
-BufferAllocator
to use for allocating data.statusCode
- Integer status code as per RFC 6455. For example, 1000 indicates normal closure.reasonText
- Reason text. Set to null if no text.
-
CloseWebSocketFrame
public CloseWebSocketFrame(BufferAllocator allocator, boolean finalFragment, int rsv)
Creates a new close frame with no losing status code and no reason text- Parameters:
allocator
-BufferAllocator
to use for allocating data.finalFragment
- flag indicating if this frame is the final fragmentrsv
- reserved bits used for protocol extensions.
-
CloseWebSocketFrame
public CloseWebSocketFrame(BufferAllocator allocator, boolean finalFragment, int rsv, int statusCode, String reasonText)
Creates a new close frame with closing status code and reason text- Parameters:
finalFragment
- flag indicating if this frame is the final fragmentrsv
- reserved bits used for protocol extensionsstatusCode
- Integer status code as per RFC 6455. For example, 1000 indicates normal closure.reasonText
- Reason text. Set to null if no text.
-
CloseWebSocketFrame
public CloseWebSocketFrame(boolean finalFragment, int rsv, Buffer binaryData)
Creates a new close frame- Parameters:
finalFragment
- flag indicating if this frame is the final fragmentrsv
- reserved bits used for protocol extensionsbinaryData
- the content of the frame. Must be 2 byte integer followed by optional UTF-8 encoded string.
-
-
Method Detail
-
statusCode
public int statusCode()
Returns the closing status code as per RFC 6455. If a status code is set, -1 is returned.
-
reasonText
public String reasonText()
Returns the reason text as per RFC 6455 If a reason text is not supplied, an empty string is returned.
-
receive
protected WebSocketFrame receive(Buffer buf)
Description copied from class:BufferHolder
Called when a sentBufferHolder
is received by the recipient. TheBufferHolder
should return a new concrete instance, that wraps the givenBuffer
object.- Specified by:
receive
in classBufferHolder<WebSocketFrame>
- Parameters:
buf
- TheBuffer
that is received by the recipient, and needs to be wrapped in a newBufferHolder
instance.- Returns:
- A new buffer holder instance, containing the given buffer.
-
-