Top Description Inners Fields Constructors Methods
org.eclipse.jetty.websocket.core

public Class CloseStatus

extends Object
Class Inheritance
Imports
java.nio.ByteBuffer, java.nio.charset.StandardCharsets, java.util.Arrays, org.eclipse.jetty.util.BufferUtil, .Utf8StringBuilder, org.eclipse.jetty.websocket.core.exception.BadPayloadException, .ProtocolException, org.eclipse.jetty.websocket.core.internal.NullAppendable

Representation of a WebSocket Close (status code & reason)

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class
public static interface

Field Summary

Modifier and TypeField and Description
public static final int
public static final int
public static final int
private final Throwable
private final int
public static final int
public static final int
pack-priv static final int
public static final int
public static final int
public static final CloseStatus
public static final int
public static final CloseStatus
public static final int
public static final CloseStatus
public static final int
public static final int
private final String
public static final int
public static final int
public static final int
public static final int
public static final int

Constructor Summary

AccessConstructor and Description
public
CloseStatus()

Creates a reason for closing a web socket connection with the no given status code.

public
CloseStatus(int
the close code
statusCode
)

Creates a reason for closing a web socket connection with the given status code and no reason phrase.

public
CloseStatus(int
the close code
statusCode
,
String
the reason phrase
reasonPhrase
)

Creates a reason for closing a web socket connection with the given status code and reason phrase.

public
CloseStatus(int
the close code
statusCode
,
Throwable
the error which caused the close
cause
)

Creates a reason for closing a web socket connection with the given status code and reason phrase.

public
CloseStatus(int
the close code
statusCode
,
String
the reason phrase
reasonPhrase
,
Throwable
the error which caused the close
cause
)

Creates a reason for closing a web socket connection with the given status code and reason phrase.

public
public

Method Summary

Modifier and TypeMethod and Description
public ByteBuffer
public static ByteBuffer
asPayloadBuffer(int statusCode, String reason)

public static String
codeString(int closeStatus)

public Throwable
public static CloseStatus
public int
public String
public boolean
public boolean
public static boolean
isOrdinary(int closeCode)

public static boolean

Returns:

true if transmittable
isTransmittableStatusCode
(int
the statusCode to test
statusCode
)

Test if provided status code can be sent/received on a WebSocket close.

public Frame
public static Frame
toFrame(int closeStatus)

public static Frame
toFrame(int closeStatus, String reason)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

private static byte[]
truncateToFit(byte[] bytes, int maxBytes)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

BAD_DATAback to summary
public static final int BAD_DATA
BAD_GATEWAYback to summary
public static final int BAD_GATEWAY
BAD_PAYLOADback to summary
public static final int BAD_PAYLOAD
causeback to summary
private final Throwable cause
codeback to summary
private final int code
EXTENSION_ERRORback to summary
public static final int EXTENSION_ERROR
FAILED_TLS_HANDSHAKEback to summary
public static final int FAILED_TLS_HANDSHAKE
MAX_REASON_PHRASEback to summary
pack-priv static final int MAX_REASON_PHRASE
MESSAGE_TOO_LARGEback to summary
public static final int MESSAGE_TOO_LARGE
NO_CLOSEback to summary
public static final int NO_CLOSE
NO_CLOSE_STATUSback to summary
public static final CloseStatus NO_CLOSE_STATUS
NO_CODEback to summary
public static final int NO_CODE
NO_CODE_STATUSback to summary
public static final CloseStatus NO_CODE_STATUS
NORMALback to summary
public static final int NORMAL
NORMAL_STATUSback to summary
public static final CloseStatus NORMAL_STATUS
POLICY_VIOLATIONback to summary
public static final int POLICY_VIOLATION
PROTOCOLback to summary
public static final int PROTOCOL
reasonback to summary
private final String reason
RESERVEDback to summary
public static final int RESERVED
SERVER_ERRORback to summary
public static final int SERVER_ERROR
SERVICE_RESTARTback to summary
public static final int SERVICE_RESTART
SHUTDOWNback to summary
public static final int SHUTDOWN
TRY_AGAIN_LATERback to summary
public static final int TRY_AGAIN_LATER

Constructor Detail

CloseStatusback to summary
public CloseStatus()

Creates a reason for closing a web socket connection with the no given status code.

CloseStatusback to summary
public CloseStatus(int statusCode)

Creates a reason for closing a web socket connection with the given status code and no reason phrase.

Parameters
statusCode:int

the close code

CloseStatusback to summary
public CloseStatus(int statusCode, String reasonPhrase)

Creates a reason for closing a web socket connection with the given status code and reason phrase.

Parameters
statusCode:int

the close code

reasonPhrase:String

the reason phrase

CloseStatusback to summary
public CloseStatus(int statusCode, Throwable cause)

Creates a reason for closing a web socket connection with the given status code and reason phrase.

Parameters
statusCode:int

the close code

cause:Throwable

the error which caused the close

CloseStatusback to summary
public CloseStatus(int statusCode, String reasonPhrase, Throwable cause)

Creates a reason for closing a web socket connection with the given status code and reason phrase.

Parameters
statusCode:int

the close code

reasonPhrase:String

the reason phrase

cause:Throwable

the error which caused the close

CloseStatusback to summary
public CloseStatus(Frame frame)
CloseStatusback to summary
public CloseStatus(ByteBuffer payload)

Method Detail

asPayloadBufferback to summary
public ByteBuffer asPayloadBuffer()
asPayloadBufferback to summary
public static ByteBuffer asPayloadBuffer(int statusCode, String reason)
codeStringback to summary
public static String codeString(int closeStatus)
getCauseback to summary
public Throwable getCause()
getCloseStatusback to summary
public static CloseStatus getCloseStatus(Frame frame)
getCodeback to summary
public int getCode()
getReasonback to summary
public String getReason()
isAbnormalback to summary
public boolean isAbnormal()
isNormalback to summary
public boolean isNormal()
isOrdinaryback to summary
public static boolean isOrdinary(int closeCode)
isTransmittableStatusCodeback to summary
public static boolean isTransmittableStatusCode(int statusCode)

Test if provided status code can be sent/received on a WebSocket close.

This honors the RFC6455 rules and IANA rules.

Parameters
statusCode:int

the statusCode to test

Returns:boolean

true if transmittable

toFrameback to summary
public Frame toFrame()
toFrameback to summary
public static Frame toFrame(int closeStatus)
toFrameback to summary
public static Frame toFrame(int closeStatus, String reason)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
truncateToFitback to summary
private static byte[] truncateToFit(byte[] bytes, int maxBytes)
org.eclipse.jetty.websocket.core back to summary

pack-priv Class CloseStatus.CloseFrame

extends Frame
implements Supplier
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.websocket.core.CloseStatus.Supplier

Field Summary

Inherited from org.eclipse.jetty.websocket.core.Frame:
finRsvOpmaskMAX_CONTROL_PAYLOADpayload

Constructor Summary

AccessConstructor and Description
public
CloseFrame(byte opcode)

public
CloseFrame(byte opCode, boolean fin, ByteBuffer payload)

Method Summary

Modifier and TypeMethod and Description
public CloseStatus
public String
toString()

Overrides org.eclipse.jetty.websocket.core.Frame.toString.

Returns a string representation of the object.

Inherited from org.eclipse.jetty.websocket.core.Frame:
asReadOnlycopycopyHeaderscopyWithoutPayloaddemaskequalsgetMaskgetOpCodegetPayloadgetPayloadAsUTF8getPayloadLengthhashCodehasPayloadhasRsvisControlFrameisDataFrameisFinisMaskedisRsv1isRsv2isRsv3resetsetFinsetMasksetOpCodesetPayloadsetPayloadsetPayloadsetRsv1setRsv2setRsv3

Constructor Detail

CloseFrameback to summary
public CloseFrame(byte opcode)
CloseFrameback to summary
public CloseFrame(byte opCode, boolean fin, ByteBuffer payload)

Method Detail

getCloseStatusback to summary
public CloseStatus getCloseStatus()

Implements org.eclipse.jetty.websocket.core.CloseStatus.Supplier.getCloseStatus.

Annotations
@Override
toStringback to summary
public String toString()

Overrides org.eclipse.jetty.websocket.core.Frame.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
org.eclipse.jetty.websocket.core back to summary

public Interface CloseStatus.Supplier

Known Direct Implementers
org.eclipse.jetty.websocket.core.CloseStatus.CloseFrame, org.eclipse.jetty.websocket.core.Frame.Parsed

Method Summary

Modifier and TypeMethod and Description
public CloseStatus

Method Detail

getCloseStatusback to summary
public CloseStatus getCloseStatus()