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 data bytes are received on a stream.</p>
55 * <p>Implementers should be read or consume the content of the
56 * {@link DataInfo} before this method returns.</p>
57 *
58 * @param stream the stream
59 * @param dataInfo the data metadata
60 */
61 public void onData(Stream stream, DataInfo dataInfo);
62
63 /**
64 * <p>Empty implementation of {@link StreamFrameListener}</p>
65 */
66 public static class Adapter implements StreamFrameListener
67 {
68 @Override
69 public void onReply(Stream stream, ReplyInfo replyInfo)
70 {
71 }
72
73 @Override
74 public void onHeaders(Stream stream, HeadersInfo headersInfo)
75 {
76 }
77
78 @Override
79 public void onData(Stream stream, DataInfo dataInfo)
80 {
81 }
82 }
83 }