# Enum WebSocketState

java.lang.Object
java.lang.Enum<WebSocketState>
com.codename1.io.WebSocketState

All Implemented Interfaces:
  `Comparable<WebSocketState>`

public enum WebSocketState extends Enum<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 Constant Summary

  Enum Constants
  Enum Constant
  Description
  `CLOSED`
  The connection is fully closed and cannot be reopened.
  `CLOSING`
  A close has been initiated (locally or by the peer); the connection is draining final frames.
  `CONNECTING`
  The connection is being negotiated.
  `OPEN`
  The handshake completed and the connection is live.

- ## Method Summary

  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.

  ### Methods inherited from class Enum

  `clone, compareTo, equals, getDeclaringClass, getEnumValues, hashCode, name, ordinal, setEnumValues, toString, valueOf`

  ### Methods inherited from class java.lang.Object

  `finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Enum Constant Details

  - ### CONNECTING

    public static final WebSocketState CONNECTING
    The connection is being negotiated. Sending messages in this state throws `IllegalStateException`.

  - ### OPEN

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

  - ### CLOSING

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

  - ### CLOSED

    public static final WebSocketState CLOSED
    The connection is fully closed and cannot be reopened. Build a new `WebSocket` to reconnect.

- ## Method Details

  - ### values

    public static WebSocketState[] values()
    Returns an array containing the constants of this enum type, in the order they are declared.
    Returns:
      an array containing the constants of this enum type, in the order they are declared

  - ### valueOf

    public static WebSocketState valueOf(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:
      `IllegalArgumentException` - if this enum type has no constant with the specified name
      `NullPointerException` - if the argument is null