View Javadoc

1   //
2   //  ========================================================================
3   //  Copyright (c) 1995-2016 Mort Bay Consulting Pty. Ltd.
4   //  ------------------------------------------------------------------------
5   //  All rights reserved. This program and the accompanying materials
6   //  are made available under the terms of the Eclipse Public License v1.0
7   //  and Apache License v2.0 which accompanies this distribution.
8   //
9   //      The Eclipse Public License is available at
10  //      http://www.eclipse.org/legal/epl-v10.html
11  //
12  //      The Apache License v2.0 is available at
13  //      http://www.opensource.org/licenses/apache2.0.php
14  //
15  //  You may elect to redistribute this code under either of these licenses.
16  //  ========================================================================
17  //
18  
19  package org.eclipse.jetty.websocket.common;
20  
21  import org.eclipse.jetty.websocket.common.io.IOState;
22  import org.eclipse.jetty.websocket.common.io.IOState.ConnectionStateListener;
23  
24  /**
25   * Connection states as outlined in <a href="https://tools.ietf.org/html/rfc6455">RFC6455</a>.
26   */
27  public enum ConnectionState
28  {
29      /** [RFC] Initial state of a connection, the upgrade request / response is in progress */
30      CONNECTING,
31      /**
32       * [Impl] Intermediate state between CONNECTING and OPEN, used to indicate that a upgrade request/response is successful, but the end-user provided socket's
33       * onOpen code has yet to run.
34       * <p>
35       * This state is to allow the local socket to initiate messages and frames, but to NOT start reading yet.
36       */
37      CONNECTED,
38      /**
39       * [RFC] The websocket connection is established and open.
40       * <p>
41       * This indicates that the Upgrade has succeed, and the end-user provided socket's onOpen code has completed.
42       * <p>
43       * It is now time to start reading from the remote endpoint.
44       */
45      OPEN,
46      /**
47       * [RFC] The websocket closing handshake is started.
48       * <p>
49       * This can be considered a half-closed state.
50       * <p>
51       * When receiving this as an event on {@link ConnectionStateListener#onConnectionStateChange(ConnectionState)} a close frame should be sent using
52       * the {@link CloseInfo} available from {@link IOState#getCloseInfo()}
53       */
54      CLOSING,
55      /**
56       * [RFC] The websocket connection is closed.
57       * <p>
58       * Connection should be disconnected and no further reads or writes should occur.
59       */
60      CLOSED;
61  }