View Javadoc

1   //========================================================================
2   //Copyright 2011-2012 Mort Bay Consulting Pty. Ltd.
3   //------------------------------------------------------------------------
4   //All rights reserved. This program and the accompanying materials
5   //are made available under the terms of the Eclipse Public License v1.0
6   //and Apache License v2.0 which accompanies this distribution.
7   //The Eclipse Public License is available at
8   //http://www.eclipse.org/legal/epl-v10.html
9   //The Apache License v2.0 is available at
10  //http://www.opensource.org/licenses/apache2.0.php
11  //You may elect to redistribute this code under either of these licenses.
12  //========================================================================
13  
14  package org.eclipse.jetty.spdy.api;
15  
16  import java.util.EventListener;
17  
18  /**
19   * <p>A {@link StreamFrameListener} is the passive counterpart of a {@link Stream} and receives
20   * events happening on a SPDY stream.</p>
21   *
22   * @see Stream
23   */
24  public interface StreamFrameListener extends EventListener
25  {
26      /**
27       * <p>Callback invoked when a reply to a stream creation has been received.</p>
28       * <p>Application code may implement this method to send more data to the other end:</p>
29       * <pre>
30       * public void onReply(Stream stream, ReplyInfo replyInfo)
31       * {
32       *     stream.data(new StringDataInfo("content"), true);
33       * }
34       * </pre>
35       * @param stream the stream
36       * @param replyInfo the reply metadata
37       */
38      public void onReply(Stream stream, ReplyInfo replyInfo);
39  
40      /**
41       * <p>Callback invoked when headers are received on a stream.</p>
42       *
43       * @param stream the stream
44       * @param headersInfo the headers metadata
45       */
46      public void onHeaders(Stream stream, HeadersInfo headersInfo);
47  
48      /**
49       * <p>Callback invoked when data bytes are received on a stream.</p>
50       * <p>Implementers should be read or consume the content of the
51       * {@link DataInfo} before this method returns.</p>
52       *
53       * @param stream the stream
54       * @param dataInfo the data metadata
55       */
56      public void onData(Stream stream, DataInfo dataInfo);
57  
58      /**
59       * <p>Empty implementation of {@link StreamFrameListener}</p>
60       */
61      public static class Adapter implements StreamFrameListener
62      {
63          @Override
64          public void onReply(Stream stream, ReplyInfo replyInfo)
65          {
66          }
67  
68          @Override
69          public void onHeaders(Stream stream, HeadersInfo headersInfo)
70          {
71          }
72  
73          @Override
74          public void onData(Stream stream, DataInfo dataInfo)
75          {
76          }
77      }
78  }