public enum WebSocketState

  1. Object
  2. Enum<WebSocketState>
  3. WebSocketState

ImplementsComparable<WebSocketState>

Lifecycle state of a WebSocket. The ordinal values match the browser WebSocket spec and java.net.http.WebSocket so platform implementations can map their native state directly.

Enum constants

CONNECTINGThe connection is being negotiated.
OPENThe handshake completed and the connection is live.
CLOSINGA close has been initiated (locally or by the peer); the connection is draining final frames.
CLOSEDThe connection is fully closed and cannot be reopened.

Methods

public static WebSocketState[] values()
public static WebSocketState valueOf(String name)

Inherited methods

Enum constant details

CONNECTING

CONNECTING
The connection is being negotiated. Sending messages in this state throws IllegalStateException.

OPEN

OPEN
The handshake completed and the connection is live. Messages can flow in both directions.

CLOSING

CLOSING
A close has been initiated (locally or by the peer); the connection is draining final frames.

CLOSED

CLOSED
The connection is fully closed and cannot be reopened. Build a new WebSocket to reconnect.

Method details

values

public static WebSocketState[] values()

valueOf

public static WebSocketState valueOf(String name)