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      /**
63       * @return the stream frame listener associated to this stream
64       */
65      public StreamFrameListener getStreamFrameListener();
66  
67      /**
68       * <p>A stream can be open, {@link #isHalfClosed() half closed} or
69       * {@link #isClosed() closed} and this method updates the close state
70       * of this stream.</p>
71       * <p>If the stream is open, calling this method with a value of true
72       * puts the stream into half closed state.</p>
73       * <p>If the stream is half closed, calling this method with a value
74       * of true puts the stream into closed state.</p>
75       *
76       * @param close whether the close state should be updated
77       * @param local whether the close is local or remote
78       */
79      public void updateCloseState(boolean close, boolean local);
80  
81      /**
82       * <p>Processes the given control frame,
83       * for example by updating the stream's state or by calling listeners.</p>
84       *
85       * @param frame the control frame to process
86       * @see #process(DataInfo)
87       */
88      public void process(ControlFrame frame);
89  
90      /**
91       * <p>Processes the given {@code dataInfo},
92       * for example by updating the stream's state or by calling listeners.</p>
93       *
94       * @param dataInfo the DataInfo to process
95       * @see #process(ControlFrame)
96       */
97      public void process(DataInfo dataInfo);
98  
99      /**
100      * <p>Associate the given {@link IStream} to this {@link IStream}.</p>
101      *
102      * @param stream the stream to associate with this stream
103      */
104     public void associate(IStream stream);
105 
106     /**
107      * <p>remove the given associated {@link IStream} from this stream</p>
108      *
109      * @param stream the stream to be removed
110      */
111     public void disassociate(IStream stream);
112 
113     /**
114      * <p>Overrides Stream.getAssociatedStream() to return an instance of IStream instead of Stream
115      *
116      * @see Stream#getAssociatedStream()
117      */
118     @Override
119     public IStream getAssociatedStream();
120 }