Enum 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

    All NeoVisionaries.WebSockets.* Code Obtained From: GitHub 'NV'  (Takahiko Kawasaki)  Public Archive.

    The initial state of a WebSocket instance is CREATED. WebSocket.connect() method is allowed to be called only when the state is CREATED. If the method is called when the state is not CREATED, a WebSocketException is thrown (its error code is NOT_IN_CREATED_STATE).

    At the beginning of the implementation of connect() method, the state is changed to CONNECTING, and then onStateChanged() 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 to CLOSED ( onStateChanged() method of listeners is called) and a WebSocketException is thrown. There are various reasons for handshake failure. If you want to know the reason, get the error code (WebSocketError) by calling getError() method of the exception.

    After the opening handshake succeeded, the state is changed to OPEN. Listeners' onStateChanged() method and onConnected() method are called in this order. Note that onConnected() 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 and onStateChanged() method of listeners is called.

    After the client and the server have exchanged close frames, the state is changed to CLOSED. Listeners' onStateChanged() method and onDisconnected() method is called in this order.

    • 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.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait