View Javadoc

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;
20  
21  import org.eclipse.jetty.spdy.api.DataInfo;
22  import org.eclipse.jetty.spdy.api.SessionFrameListener;
23  import org.eclipse.jetty.spdy.api.Stream;
24  import org.eclipse.jetty.spdy.api.StreamFrameListener;
25  import org.eclipse.jetty.spdy.api.SynInfo;
26  import org.eclipse.jetty.spdy.frames.ControlFrame;
27  import org.eclipse.jetty.util.Callback;
28  
29  /**
30   * <p>The internal interface that represents a stream.</p>
31   * <p>{@link IStream} contains additional methods used by a SPDY
32   * implementation (and not by an application).</p>
33   */
34  public interface IStream extends Stream, Callback
35  {
36      /**
37       * <p>Senders of data frames need to know the current window size
38       * to determine whether they can send more data.</p>
39       *
40       * @return the current window size for this stream.
41       * @see #updateWindowSize(int)
42       */
43      public int getWindowSize();
44  
45      /**
46       * <p>Updates the window size for this stream by the given amount,
47       * that can be positive or negative.</p>
48       * <p>Senders and recipients of data frames update the window size,
49       * respectively, with negative values and positive values.</p>
50       *
51       * @param delta the signed amount the window size needs to be updated
52       * @see #getWindowSize()
53       */
54      public void updateWindowSize(int delta);
55  
56      /**
57       * @param listener the stream frame listener associated to this stream
58       * as returned by {@link SessionFrameListener#onSyn(Stream, SynInfo)}
59       */
60      public void setStreamFrameListener(StreamFrameListener listener);
61  
62      //TODO: javadoc thomas
63      public StreamFrameListener getStreamFrameListener();
64  
65      /**
66       * <p>A stream can be open, {@link #isHalfClosed() half closed} or
67       * {@link #isClosed() closed} and this method updates the close state
68       * of this stream.</p>
69       * <p>If the stream is open, calling this method with a value of true
70       * puts the stream into half closed state.</p>
71       * <p>If the stream is half closed, calling this method with a value
72       * of true puts the stream into closed state.</p>
73       *
74       * @param close whether the close state should be updated
75       * @param local whether the close is local or remote
76       */
77      public void updateCloseState(boolean close, boolean local);
78  
79      /**
80       * <p>Processes the given control frame,
81       * for example by updating the stream's state or by calling listeners.</p>
82       *
83       * @param frame the control frame to process
84       * @see #process(DataInfo)
85       */
86      public void process(ControlFrame frame);
87  
88      /**
89       * <p>Processes the given {@code dataInfo},
90       * for example by updating the stream's state or by calling listeners.</p>
91       *
92       * @param dataInfo the DataInfo to process
93       * @see #process(ControlFrame)
94       */
95      public void process(DataInfo dataInfo);
96  
97      /**
98       * <p>Associate the given {@link IStream} to this {@link IStream}.</p>
99       *
100      * @param stream the stream to associate with this stream
101      */
102     public void associate(IStream stream);
103 
104     /**
105      * <p>remove the given associated {@link IStream} from this stream</p>
106      *
107      * @param stream the stream to be removed
108      */
109     public void disassociate(IStream stream);
110 
111     /**
112      * <p>Overrides Stream.getAssociatedStream() to return an instance of IStream instead of Stream
113      *
114      * @see Stream#getAssociatedStream()
115      */
116     @Override
117     public IStream getAssociatedStream();
118 }