View Javadoc
1   /*
2    * Copyright 2014 The Netty Project
3    *
4    * The Netty Project licenses this file to you under the Apache License, version 2.0 (the
5    * "License"); you may not use this file except in compliance with the License. You may obtain a
6    * 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 distributed under the License
11   * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing permissions and limitations under
13   * the License.
14   */
15  package io.netty.handler.codec.http2;
16  
17  import io.netty.buffer.ByteBuf;
18  import io.netty.channel.ChannelFuture;
19  import io.netty.channel.ChannelHandlerContext;
20  import io.netty.channel.ChannelPromise;
21  
22  
23  /**
24   * Handler for outbound HTTP/2 traffic.
25   */
26  public interface Http2ConnectionEncoder extends Http2FrameWriter {
27  
28      /**
29       * Builder for new instances of {@link Http2ConnectionEncoder}.
30       */
31      interface Builder {
32  
33          /**
34           * Sets the {@link Http2Connection} to be used when building the encoder.
35           */
36          Builder connection(Http2Connection connection);
37  
38          /**
39           * Sets the {@link Http2LifecycleManager} to be used when building the encoder.
40           */
41          Builder lifecycleManager(Http2LifecycleManager lifecycleManager);
42  
43          /**
44           * Gets the {@link Http2LifecycleManager} to be used when building the encoder.
45           */
46          Http2LifecycleManager lifecycleManager();
47  
48          /**
49           * Sets the {@link Http2FrameWriter} to be used when building the encoder.
50           */
51          Builder frameWriter(Http2FrameWriter frameWriter);
52  
53          /**
54           * Creates a new encoder instance.
55           */
56          Http2ConnectionEncoder build();
57      }
58  
59      /**
60       * Provides direct access to the underlying connection.
61       */
62      Http2Connection connection();
63  
64      /**
65       * Provides the remote flow controller for managing outbound traffic.
66       */
67      Http2RemoteFlowController flowController();
68  
69      /**
70       * Provides direct access to the underlying frame writer object.
71       */
72      Http2FrameWriter frameWriter();
73  
74      /**
75       * Gets the local settings on the top of the queue that has been sent but not ACKed. This may
76       * return {@code null}.
77       */
78      Http2Settings pollSentSettings();
79  
80      /**
81       * Sets the settings for the remote endpoint of the HTTP/2 connection.
82       */
83      void remoteSettings(Http2Settings settings) throws Http2Exception;
84  
85      /**
86       * Writes the given data to the internal {@link Http2FrameWriter} without performing any
87       * state checks on the connection/stream.
88       */
89      @Override
90      ChannelFuture writeFrame(ChannelHandlerContext ctx, byte frameType, int streamId,
91              Http2Flags flags, ByteBuf payload, ChannelPromise promise);
92  }