View Javadoc

1   //
2   //  ========================================================================
3   //  Copyright (c) 1995-2013 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  /**
26   * Connection states as outlined in <a href="https://tools.ietf.org/html/rfc6455">RFC6455</a>.
27   */
28  public enum ConnectionState
29  {
30      /** [RFC] Initial state of a connection, the upgrade request / response is in progress */
31      CONNECTING,
32      /**
33       * [Impl] Intermediate state between CONNECTING and OPEN, used to indicate that a upgrade request/response is successful, but the end-user provided socket's
34       * onOpen code has yet to run.
35       * <p>
36       * This state is to allow the local socket to initiate messages and frames, but to NOT start reading yet.
37       */
38      CONNECTED,
39      /**
40       * [RFC] The websocket connection is established and open.
41       * <p>
42       * This indicates that the Upgrade has succeed, and the end-user provided socket's onOpen code has completed.
43       * <p>
44       * It is now time to start reading from the remote endpoint.
45       */
46      OPEN,
47      /**
48       * [RFC] The websocket closing handshake is started.
49       * <p>
50       * This can be considered a half-closed state.
51       * <p>
52       * When receiving this as an event on {@link ConnectionStateListener#onConnectionStateChange(ConnectionState)} a close frame should be sent using
53       * the {@link CloseInfo} available from {@link IOState#getCloseInfo()}
54       */
55      CLOSING,
56      /**
57       * [RFC] The websocket connection is closed.
58       * <p>
59       * Connection should be disconnected and no further reads or writes should occur.
60       */
61      CLOSED;
62  }