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.api; 20 21 /** 22 * Core WebSocket Connection Listener 23 */ 24 public interface WebSocketConnectionListener 25 { 26 /** 27 * A Close Event was received. 28 * <p> 29 * The underlying Connection will be considered closed at this point. 30 * 31 * @param statusCode 32 * the close status code. (See {@link StatusCode}) 33 * @param reason 34 * the optional reason for the close. 35 */ 36 void onWebSocketClose(int statusCode, String reason); 37 38 /** 39 * A WebSocket {@link Session} has connected successfully and is ready to be used. 40 * <p> 41 * Note: It is a good idea to track this session as a field in your object so that you can write messages back via the {@link RemoteEndpoint} 42 * 43 * @param session 44 * the websocket session. 45 */ 46 void onWebSocketConnect(Session session); 47 48 /** 49 * A WebSocket exception has occurred. 50 * <p> 51 * This is a way for the internal implementation to notify of exceptions occured during the processing of websocket. 52 * <p> 53 * Usually this occurs from bad / malformed incoming packets. (example: bad UTF8 data, frames that are too big, violations of the spec) 54 * <p> 55 * This will result in the {@link Session} being closed by the implementing side. 56 * 57 * @param cause 58 * the error that occurred. 59 */ 60 void onWebSocketError(Throwable cause); 61 }