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