Enum WebSocketState
- java.lang.Object
-
- java.lang.Enum<WebSocketState>
-
- NeoVisionaries.WebSockets.WebSocketState
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<WebSocketState>
public enum WebSocketState extends java.lang.Enum<WebSocketState>
WebSocket state.
Read included Apache License 2.0:HERE
AllNeoVisionaries.WebSockets.*
Code Obtained From:GitHub 'NV' (Takahiko Kawasaki)
Public Archive.
The initial state of a
WebSocket
instance isCREATED
.WebSocket.
connect()
method is allowed to be called only when the state isCREATED
. If the method is called when the state is notCREATED
, aWebSocketException
is thrown (its error code isNOT_IN_CREATED_STATE
).At the beginning of the implementation of
connect()
method, the state is changed toCONNECTING
, and thenonStateChanged()
method of each registered listener (WebSocketListener
) is called.After the state is changed to
CONNECTING
, a WebSocket opening handshake is performed. If an error occurred during the handshake, the state is changed toCLOSED
(onStateChanged()
method of listeners is called) and aWebSocketException
is thrown. There are various reasons for handshake failure. If you want to know the reason, get the error code (WebSocketError
) by callinggetError()
method of the exception.After the opening handshake succeeded, the state is changed to
OPEN
. Listeners'onStateChanged()
method andonConnected()
method are called in this order. Note thatonConnected()
method is called by another thread.Upon either sending or receiving a close frame, a closing handshake is started. The state is changed to
CLOSING
andonStateChanged()
method of listeners is called.After the client and the server have exchanged close frames, the state is changed to
CLOSED
. Listeners'onStateChanged()
method andonDisconnected()
method is called in this order.
Hi-Lited Source-Code:- View Here: NeoVisionaries/WebSockets/WebSocketState.java
- Open New Browser-Tab: NeoVisionaries/WebSockets/WebSocketState.java
File Size: 3,820 Bytes Line Count: 114 '\n' Characters Found
-
-
Enum Constant Summary
Enum Constants Enum Constant Description CLOSED
The WebSocket connection is closed.CLOSING
A closing handshake is being performed.CONNECTING
An opening handshake is being performed.CREATED
The initial state of aWebSocket
instance.OPEN
The WebSocket connection is established (= the opening handshake has succeeded) and usable.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static WebSocketState
valueOf(String name)
Returns the enum constant of this type with the specified name.static WebSocketState[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
CREATED
public static final WebSocketState CREATED
The initial state of aWebSocket
instance.
-
CONNECTING
public static final WebSocketState CONNECTING
An opening handshake is being performed.
-
OPEN
public static final WebSocketState OPEN
The WebSocket connection is established (= the opening handshake has succeeded) and usable.
-
CLOSING
public static final WebSocketState CLOSING
A closing handshake is being performed.
-
CLOSED
public static final WebSocketState CLOSED
The WebSocket connection is closed.
-
-
Method Detail
-
values
public static WebSocketState[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (WebSocketState c : WebSocketState.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static WebSocketState valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
-