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