Top Description Constructors Methods
io.netty5.handler.codec.http.websocketx

public Class CloseWebSocketFrame

extends WebSocketFrame
Class Inheritance
Imports
io.netty5.buffer.Buffer, .BufferAllocator, io.netty5.util.internal.StringUtil, java.nio.charset.StandardCharsets

Web Socket Frame for closing the connection.

Constructor Summary

AccessConstructor and Description
public
CloseWebSocketFrame(BufferAllocator
BufferAllocator to use for allocating data.
allocator
,
WebSocketCloseStatus
Status code as per RFC 6455. For example, 1000 indicates normal closure.
status
)

Creates a new empty close frame with closing status code and reason text

public
CloseWebSocketFrame(BufferAllocator
BufferAllocator to use for allocating data.
allocator
,
WebSocketCloseStatus
Status code as per RFC 6455. For example, 1000 indicates normal closure.
status
,
String
Reason text. Set to null if no text.
reasonText
)

Creates a new empty close frame with closing status code and reason text

public
CloseWebSocketFrame(BufferAllocator
BufferAllocator to use for allocating data.
allocator
,
int
Integer status code as per RFC 6455. For example, 1000 indicates normal closure.
statusCode
,
String
Reason text. Set to null if no text.
reasonText
)

Creates a new empty close frame with closing status code and reason text

public
CloseWebSocketFrame(BufferAllocator
BufferAllocator to use for allocating data.
allocator
,
boolean
flag indicating if this frame is the final fragment
finalFragment
,
int
reserved bits used for protocol extensions.
rsv
)

Creates a new close frame with no losing status code and no reason text

public
CloseWebSocketFrame(BufferAllocator allocator, boolean
flag indicating if this frame is the final fragment
finalFragment
,
int
reserved bits used for protocol extensions
rsv
,
int
Integer status code as per RFC 6455. For example, 1000 indicates normal closure.
statusCode
,
String
Reason text. Set to null if no text.
reasonText
)

Creates a new close frame with closing status code and reason text

public
CloseWebSocketFrame(boolean
flag indicating if this frame is the final fragment
finalFragment
,
int
reserved bits used for protocol extensions
rsv
,
Buffer
the content of the frame. Must be 2 byte integer followed by optional UTF-8 encoded string.
binaryData
)

Creates a new close frame

private

Method Summary

Modifier and TypeMethod and Description
private static Buffer
newBinaryData(BufferAllocator allocator, short statusCode, String reasonText)

public 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
The Buffer that is received by the recipient, and needs to be wrapped in a new BufferHolder instance.
buf
)

Implements abstract io.netty5.buffer.BufferHolder.receive.

Called when a sent BufferHolder is received by the recipient.
pack-priv static short
requireValidStatusCode(int statusCode)

public int
statusCode()

Returns the closing status code as per RFC 6455.

Inherited from io.netty5.handler.codec.http.websocketx.WebSocketFrame:
binaryDataisFinalFragmentrsvtoString

Constructor Detail

CloseWebSocketFrameback to summary
public CloseWebSocketFrame(BufferAllocator allocator, WebSocketCloseStatus status)

Creates a new empty close frame with closing status code and reason text

Parameters
allocator:BufferAllocator

BufferAllocator to use for allocating data.

status:WebSocketCloseStatus

Status code as per RFC 6455. For example, 1000 indicates normal closure.

CloseWebSocketFrameback to summary
public CloseWebSocketFrame(BufferAllocator allocator, WebSocketCloseStatus status, String reasonText)

Creates a new empty close frame with closing status code and reason text

Parameters
allocator:BufferAllocator

BufferAllocator to use for allocating data.

status:WebSocketCloseStatus

Status code as per RFC 6455. For example, 1000 indicates normal closure.

reasonText:String

Reason text. Set to null if no text.

CloseWebSocketFrameback to summary
public CloseWebSocketFrame(BufferAllocator allocator, int statusCode, String reasonText)

Creates a new empty close frame with closing status code and reason text

Parameters
allocator:BufferAllocator

BufferAllocator to use for allocating data.

statusCode:int

Integer status code as per RFC 6455. For example, 1000 indicates normal closure.

reasonText:String

Reason text. Set to null if no text.

CloseWebSocketFrameback to summary
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

BufferAllocator to use for allocating data.

finalFragment:boolean

flag indicating if this frame is the final fragment

rsv:int

reserved bits used for protocol extensions.

CloseWebSocketFrameback to summary
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:boolean

flag indicating if this frame is the final fragment

rsv:int

reserved bits used for protocol extensions

statusCode:int

Integer status code as per RFC 6455. For example, 1000 indicates normal closure.

reasonText:String

Reason text. Set to null if no text.

CloseWebSocketFrameback to summary
public CloseWebSocketFrame(boolean finalFragment, int rsv, Buffer binaryData)

Creates a new close frame

Parameters
finalFragment:boolean

flag indicating if this frame is the final fragment

rsv:int

reserved bits used for protocol extensions

binaryData:Buffer

the content of the frame. Must be 2 byte integer followed by optional UTF-8 encoded string.

CloseWebSocketFrameback to summary
private CloseWebSocketFrame(CloseWebSocketFrame copyFrom, Buffer data)

Method Detail

newBinaryDataback to summary
private static Buffer newBinaryData(BufferAllocator allocator, short statusCode, String reasonText)
reasonTextback to summary
public String reasonText()

Returns the reason text as per RFC 6455 If a reason text is not supplied, an empty string is returned.

receiveback to summary
protected WebSocketFrame receive(Buffer buf)

Implements abstract io.netty5.buffer.BufferHolder.receive.

Doc from io.netty5.buffer.BufferHolder.receive.

Called when a sent BufferHolder is received by the recipient. The BufferHolder should return a new concrete instance, that wraps the given Buffer object.

Parameters
buf:Buffer

The Buffer that is received by the recipient, and needs to be wrapped in a new BufferHolder instance.

Returns:WebSocketFrame

A new buffer holder instance, containing the given buffer.

Annotations
@Override
requireValidStatusCodeback to summary
pack-priv static short requireValidStatusCode(int statusCode)
statusCodeback to summary
public int statusCode()

Returns the closing status code as per RFC 6455. If a status code is set, -1 is returned.