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 import java.nio.ByteBuffer; 22 23 /** 24 * WebSocket Partial Message Listener interface for incoming WebSocket TEXT/BINARY/CONTINUATION frames. 25 */ 26 public interface WebSocketPartialListener extends WebSocketConnectionListener 27 { 28 /** 29 * A WebSocket BINARY (or associated CONTINUATION) frame has been received. 30 * <p> 31 * <b>Important Note</b>: The payload <code>ByteBuffer</code> cannot be modified, and the ByteBuffer object itself 32 * will be recycled on completion of this method call, make a copy of the data contained within if you want to 33 * retain it between calls. 34 * 35 * @param payload 36 * the binary message frame payload 37 * @param fin 38 * true if this is the final frame, false otherwise 39 */ 40 void onWebSocketPartialBinary(ByteBuffer payload, boolean fin); 41 42 /** 43 * A WebSocket TEXT (or associated CONTINUATION) frame has been received. 44 * 45 * @param payload 46 * the text message payload 47 * <p> 48 * Note that due to framing, there is a above average chance of any UTF8 sequences being split on the 49 * border between two frames will result in either the previous frame, or the next frame having an 50 * invalid UTF8 sequence, but the combined frames having a valid UTF8 sequence. 51 * <p> 52 * The String being provided here will not end in a split UTF8 sequence. Instead this partial sequence 53 * will be held over until the next frame is received. 54 * @param fin 55 * true if this is the final frame, false otherwise 56 */ 57 void onWebSocketPartialText(String payload, boolean fin); 58 }