View Javadoc

1   /*
2    * Copyright (c) 2012 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.eclipse.jetty.spdy;
18  
19  import java.nio.ByteBuffer;
20  
21  import org.eclipse.jetty.spdy.api.SessionFrameListener;
22  import org.eclipse.jetty.spdy.api.Stream;
23  import org.eclipse.jetty.spdy.api.StreamFrameListener;
24  import org.eclipse.jetty.spdy.api.SynInfo;
25  import org.eclipse.jetty.spdy.frames.ControlFrame;
26  import org.eclipse.jetty.spdy.frames.DataFrame;
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(DataFrame, ByteBuffer)
81       */
82      public void process(ControlFrame frame);
83  
84      /**
85       * <p>Processes the give data frame along with the given byte buffer,
86       * for example by updating the stream's state or by calling listeners.</p>
87       *
88       * @param frame the data frame to process
89       * @param data the byte buffer to process
90       * @see #process(ControlFrame)
91       */
92      public void process(DataFrame frame, ByteBuffer data);
93  }