Package org.java_websocket.framing
Class CloseFrame
java.lang.Object
org.java_websocket.framing.FramedataImpl1
org.java_websocket.framing.ControlFrame
org.java_websocket.framing.CloseFrame
- All Implemented Interfaces:
Framedata
Class to represent a close frame
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int1006 is a reserved value and MUST NOT be set as a status code in a Close control frame by an endpoint.static final int1014 indicates that the server was acting as a gateway or proxy and received an invalid response from the upstream server.static final intThe connection had a buggy close (this should not happen)static final int1010 indicates that an endpoint (client) is terminating the connection because it has expected the server to negotiate one or more extension, but the server didn't return them in the response message of the WebSocket handshake.static final intThe connection was flushed and closedstatic final int1001 indicates that an endpoint is "going away", such as a server going down, or a browser having navigated away from a page.static final intThe connection had never been establishedstatic final int1007 indicates that an endpoint is terminating the connection because it has received data within a message that was not consistent with the type of the message (e.g., non-UTF-8 [RFC3629] data within a text message).static final int1005 is a reserved value and MUST NOT be set as a status code in a Close control frame by an endpoint.static final intindicates a normal closure, meaning whatever purpose the connection was established for has been fulfilled.static final int1008 indicates that an endpoint is terminating the connection because it has received a message that violates its policy.static final int1002 indicates that an endpoint is terminating the connection due to a protocol error.static final int1003 indicates that an endpoint is terminating the connection because it has received a type of data it cannot accept (e.g. an endpoint that understands only text data MAY send this if it receives a binary message).static final int1012 indicates that the service is restarted.static final int1015 is a reserved value and MUST NOT be set as a status code in a Close control frame by an endpoint.static final int1009 indicates that an endpoint is terminating the connection because it has received a message which is too big for it to process.static final int1013 indicates that the service is experiencing overload.static final int1011 indicates that a server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanintGet the used close codeGet the message that closeframe is containingThe "Payload data" which was sent in this frameinthashCode()voidisValid()Check if the frame is valid due to specificationvoidsetCode(int code) Set the close code for this close framevoidsetPayload(ByteBuffer payload) Set the payload of this frame to the provided payloadvoidSet the close reason for this close frametoString()Methods inherited from class org.java_websocket.framing.FramedataImpl1
append, get, getOpcode, getTransfereMasked, isFin, isRSV1, isRSV2, isRSV3, setFin, setRSV1, setRSV2, setRSV3, setTransferemasked
-
Field Details
-
NORMAL
public static final int NORMALindicates a normal closure, meaning whatever purpose the connection was established for has been fulfilled.- See Also:
-
GOING_AWAY
public static final int GOING_AWAY1001 indicates that an endpoint is "going away", such as a server going down, or a browser having navigated away from a page.- See Also:
-
PROTOCOL_ERROR
public static final int PROTOCOL_ERROR1002 indicates that an endpoint is terminating the connection due to a protocol error.- See Also:
-
REFUSE
public static final int REFUSE1003 indicates that an endpoint is terminating the connection because it has received a type of data it cannot accept (e.g. an endpoint that understands only text data MAY send this if it receives a binary message).- See Also:
-
NOCODE
public static final int NOCODE1005 is a reserved value and MUST NOT be set as a status code in a Close control frame by an endpoint. It is designated for use in applications expecting a status code to indicate that no status code was actually present.- See Also:
-
ABNORMAL_CLOSE
public static final int ABNORMAL_CLOSE1006 is a reserved value and MUST NOT be set as a status code in a Close control frame by an endpoint. It is designated for use in applications expecting a status code to indicate that the connection was closed abnormally, e.g. without sending or receiving a Close control frame.- See Also:
-
NO_UTF8
public static final int NO_UTF81007 indicates that an endpoint is terminating the connection because it has received data within a message that was not consistent with the type of the message (e.g., non-UTF-8 [RFC3629] data within a text message).- See Also:
-
POLICY_VALIDATION
public static final int POLICY_VALIDATION1008 indicates that an endpoint is terminating the connection because it has received a message that violates its policy. This is a generic status code that can be returned when there is no other more suitable status code (e.g. 1003 or 1009), or if there is a need to hide specific details about the policy.- See Also:
-
TOOBIG
public static final int TOOBIG1009 indicates that an endpoint is terminating the connection because it has received a message which is too big for it to process.- See Also:
-
EXTENSION
public static final int EXTENSION1010 indicates that an endpoint (client) is terminating the connection because it has expected the server to negotiate one or more extension, but the server didn't return them in the response message of the WebSocket handshake. The list of extensions which are needed SHOULD appear in the /reason/ part of the Close frame. Note that this status code is not used by the server, because it can fail the WebSocket handshake instead.- See Also:
-
UNEXPECTED_CONDITION
public static final int UNEXPECTED_CONDITION1011 indicates that a server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request.- See Also:
-
SERVICE_RESTART
public static final int SERVICE_RESTART1012 indicates that the service is restarted. A client may reconnect, and if it choses to do, should reconnect using a randomized delay of 5 - 30s. See https://www.ietf.org/mail-archive/web/hybi/current/msg09670.html for more information.- Since:
- 1.3.8
- See Also:
-
TRY_AGAIN_LATER
public static final int TRY_AGAIN_LATER1013 indicates that the service is experiencing overload. A client should only connect to a different IP (when there are multiple for the target) or reconnect to the same IP upon user action. See https://www.ietf.org/mail-archive/web/hybi/current/msg09670.html for more information.- Since:
- 1.3.8
- See Also:
-
BAD_GATEWAY
public static final int BAD_GATEWAY1014 indicates that the server was acting as a gateway or proxy and received an invalid response from the upstream server. This is similar to 502 HTTP Status Code See https://www.ietf.org/mail-archive/web/hybi/current/msg10748.html fore more information.- Since:
- 1.3.8
- See Also:
-
TLS_ERROR
public static final int TLS_ERROR1015 is a reserved value and MUST NOT be set as a status code in a Close control frame by an endpoint. It is designated for use in applications expecting a status code to indicate that the connection was closed due to a failure to perform a TLS handshake (e.g., the server certificate can't be verified).- See Also:
-
NEVER_CONNECTED
public static final int NEVER_CONNECTEDThe connection had never been established- See Also:
-
BUGGYCLOSE
public static final int BUGGYCLOSEThe connection had a buggy close (this should not happen)- See Also:
-
FLASHPOLICY
public static final int FLASHPOLICYThe connection was flushed and closed- See Also:
-
-
Constructor Details
-
CloseFrame
public CloseFrame()Constructor for a close frameUsing opcode closing and fin = true
-
-
Method Details
-
setCode
public void setCode(int code) Set the close code for this close frame- Parameters:
code- the close code
-
setReason
Set the close reason for this close frame- Parameters:
reason- the reason code
-
getCloseCode
public int getCloseCode()Get the used close code- Returns:
- the used close code
-
getMessage
Get the message that closeframe is containing- Returns:
- the message in this frame
-
toString
- Overrides:
toStringin classFramedataImpl1
-
isValid
Description copied from class:FramedataImpl1Check if the frame is valid due to specification- Overrides:
isValidin classControlFrame- Throws:
InvalidDataException- thrown if the frame is not a valid frame
-
setPayload
Description copied from class:FramedataImpl1Set the payload of this frame to the provided payload- Overrides:
setPayloadin classFramedataImpl1- Parameters:
payload- the payload which is to set
-
getPayloadData
Description copied from interface:FramedataThe "Payload data" which was sent in this frame- Specified by:
getPayloadDatain interfaceFramedata- Overrides:
getPayloadDatain classFramedataImpl1- Returns:
- the "Payload data" as ByteBuffer
-
equals
- Overrides:
equalsin classFramedataImpl1
-
hashCode
public int hashCode()- Overrides:
hashCodein classFramedataImpl1
-