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.spdy.api; 20 21 import java.util.EventListener; 22 23 /** 24 * <p>A {@link StreamFrameListener} is the passive counterpart of a {@link Stream} and receives 25 * events happening on a SPDY stream.</p> 26 * 27 * @see Stream 28 */ 29 public interface StreamFrameListener extends EventListener 30 { 31 /** 32 * <p>Callback invoked when a reply to a stream creation has been received.</p> 33 * <p>Application code may implement this method to send more data to the other end:</p> 34 * <pre> 35 * public void onReply(Stream stream, ReplyInfo replyInfo) 36 * { 37 * stream.data(new StringDataInfo("content"), true); 38 * } 39 * </pre> 40 * @param stream the stream 41 * @param replyInfo the reply metadata 42 */ 43 public void onReply(Stream stream, ReplyInfo replyInfo); 44 45 /** 46 * <p>Callback invoked when headers are received on a stream.</p> 47 * 48 * @param stream the stream 49 * @param headersInfo the headers metadata 50 */ 51 public void onHeaders(Stream stream, HeadersInfo headersInfo); 52 53 /** 54 * <p>Callback invoked when a push syn has been received on a stream.</p> 55 * 56 * @param stream the push stream just created 57 * @param pushInfo 58 * @return a listener for stream events or null if there is no interest in being notified of stream events 59 */ 60 public StreamFrameListener onPush(Stream stream, PushInfo pushInfo); 61 62 /** 63 * <p>Callback invoked when data bytes are received on a stream.</p> 64 * <p>Implementers should be read or consume the content of the 65 * {@link DataInfo} before this method returns.</p> 66 * 67 * @param stream the stream 68 * @param dataInfo the data metadata 69 */ 70 public void onData(Stream stream, DataInfo dataInfo); 71 72 /** 73 * <p>Empty implementation of {@link StreamFrameListener}</p> 74 */ 75 public static class Adapter implements StreamFrameListener 76 { 77 @Override 78 public void onReply(Stream stream, ReplyInfo replyInfo) 79 { 80 } 81 82 @Override 83 public void onHeaders(Stream stream, HeadersInfo headersInfo) 84 { 85 } 86 87 @Override 88 public StreamFrameListener onPush(Stream stream, PushInfo pushInfo) 89 { 90 return null; 91 } 92 93 @Override 94 public void onData(Stream stream, DataInfo dataInfo) 95 { 96 } 97 } 98 }