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