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