Home / Function/ handleOutboundMessage() — netty Function Reference

handleOutboundMessage() — netty Function Reference

Architecture documentation for the handleOutboundMessage() function in SpdySessionHandler.java from the netty codebase.

Function java Buffer Allocators calls 8 called by 1

Entity Profile

Dependency Diagram

graph TD
  ec4cd550_8624_c011_7fc2_e23fed71bcc1["handleOutboundMessage()"]
  1fb79984_fd8e_cecc_3934_20ed3529f561["SpdySessionHandler"]
  ec4cd550_8624_c011_7fc2_e23fed71bcc1 -->|defined in| 1fb79984_fd8e_cecc_3934_20ed3529f561
  07a6926c_53d4_0712_b28c_9bfc902c90c9["write()"]
  07a6926c_53d4_0712_b28c_9bfc902c90c9 -->|calls| ec4cd550_8624_c011_7fc2_e23fed71bcc1
  0bbd9d3a_603a_1f42_0a30_c790b2a786c5["updateSendWindowSize()"]
  ec4cd550_8624_c011_7fc2_e23fed71bcc1 -->|calls| 0bbd9d3a_603a_1f42_0a30_c790b2a786c5
  07a6926c_53d4_0712_b28c_9bfc902c90c9["write()"]
  ec4cd550_8624_c011_7fc2_e23fed71bcc1 -->|calls| 07a6926c_53d4_0712_b28c_9bfc902c90c9
  d9e20c4c_0d4b_8b85_52cd_ff50b2c773f1["issueSessionError()"]
  ec4cd550_8624_c011_7fc2_e23fed71bcc1 -->|calls| d9e20c4c_0d4b_8b85_52cd_ff50b2c773f1
  fd4b4a14_de0e_f563_d7f8_c8f51694e4f6["halfCloseStream()"]
  ec4cd550_8624_c011_7fc2_e23fed71bcc1 -->|calls| fd4b4a14_de0e_f563_d7f8_c8f51694e4f6
  05b1923a_38e1_1014_132a_6e3154a42d84["isRemoteInitiatedId()"]
  ec4cd550_8624_c011_7fc2_e23fed71bcc1 -->|calls| 05b1923a_38e1_1014_132a_6e3154a42d84
  48161a49_383a_2f23_c7eb_f67d5d02bbc6["acceptStream()"]
  ec4cd550_8624_c011_7fc2_e23fed71bcc1 -->|calls| 48161a49_383a_2f23_c7eb_f67d5d02bbc6
  9259efc1_c40e_efc0_2d75_ce800778ec12["removeStream()"]
  ec4cd550_8624_c011_7fc2_e23fed71bcc1 -->|calls| 9259efc1_c40e_efc0_2d75_ce800778ec12
  7458b225_6f9a_5cab_a9c4_c8f352e67d6c["updateInitialReceiveWindowSize()"]
  ec4cd550_8624_c011_7fc2_e23fed71bcc1 -->|calls| 7458b225_6f9a_5cab_a9c4_c8f352e67d6c
  style ec4cd550_8624_c011_7fc2_e23fed71bcc1 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySessionHandler.java lines 453–640

    private void handleOutboundMessage(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
        if (msg instanceof SpdyDataFrame) {

            SpdyDataFrame spdyDataFrame = (SpdyDataFrame) msg;
            int streamId = spdyDataFrame.streamId();

            // Frames must not be sent on half-closed streams
            if (spdySession.isLocalSideClosed(streamId)) {
                spdyDataFrame.release();
                promise.setFailure(PROTOCOL_EXCEPTION);
                return;
            }

            /*
             * SPDY Data frame flow control processing requirements:
             *
             * Sender must not send a data frame with data length greater
             * than the transfer window size.
             *
             * After sending each data frame, the sender decrements its
             * transfer window size by the amount of data transmitted.
             *
             * When the window size becomes less than or equal to 0, the
             * sender must pause transmitting data frames.
             */

            int dataLength = spdyDataFrame.content().readableBytes();
            int sendWindowSize = spdySession.getSendWindowSize(streamId);
            int sessionSendWindowSize = spdySession.getSendWindowSize(SPDY_SESSION_STREAM_ID);
            sendWindowSize = Math.min(sendWindowSize, sessionSendWindowSize);

            if (sendWindowSize <= 0) {
                // Stream is stalled -- enqueue Data frame and return
                spdySession.putPendingWrite(streamId, new SpdySession.PendingWrite(spdyDataFrame, promise));
                return;
            } else if (sendWindowSize < dataLength) {
                // Stream is not stalled but we cannot send the entire frame
                spdySession.updateSendWindowSize(streamId, -1 * sendWindowSize);
                spdySession.updateSendWindowSize(SPDY_SESSION_STREAM_ID, -1 * sendWindowSize);

                // Create a partial data frame whose length is the current window size
                SpdyDataFrame partialDataFrame = new DefaultSpdyDataFrame(
                        streamId, spdyDataFrame.content().readRetainedSlice(sendWindowSize));

                // Enqueue the remaining data (will be the first frame queued)
                spdySession.putPendingWrite(streamId, new SpdySession.PendingWrite(spdyDataFrame, promise));

                // The transfer window size is pre-decremented when sending a data frame downstream.
                // Close the session on write failures that leave the transfer window in a corrupt state.
                final ChannelHandlerContext context = ctx;
                ctx.write(partialDataFrame).addListener(future -> {
                    if (!future.isSuccess()) {
                        issueSessionError(context, SpdySessionStatus.INTERNAL_ERROR);
                    }
                });
                return;
            } else {
                // Window size is large enough to send entire data frame
                spdySession.updateSendWindowSize(streamId, -1 * dataLength);
                spdySession.updateSendWindowSize(SPDY_SESSION_STREAM_ID, -1 * dataLength);

                // The transfer window size is pre-decremented when sending a data frame downstream.
                // Close the session on write failures that leave the transfer window in a corrupt state.
                final ChannelHandlerContext context = ctx;
                promise.addListener(future -> {
                    if (!future.isSuccess()) {
                        issueSessionError(context, SpdySessionStatus.INTERNAL_ERROR);
                    }
                });
            }

            // Close the local side of the stream if this is the last frame
            if (spdyDataFrame.isLast()) {
                halfCloseStream(streamId, false, promise);
            }

        } else if (msg instanceof SpdySynStreamFrame) {

            SpdySynStreamFrame spdySynStreamFrame = (SpdySynStreamFrame) msg;
            int streamId = spdySynStreamFrame.streamId();

Domain

Subdomains

Called By

Frequently Asked Questions

What does handleOutboundMessage() do?
handleOutboundMessage() is a function in the netty codebase, defined in codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySessionHandler.java.
Where is handleOutboundMessage() defined?
handleOutboundMessage() is defined in codec-http/src/main/java/io/netty/handler/codec/spdy/SpdySessionHandler.java at line 453.
What does handleOutboundMessage() call?
handleOutboundMessage() calls 8 function(s): acceptStream, halfCloseStream, isRemoteInitiatedId, issueSessionError, removeStream, updateInitialReceiveWindowSize, updateSendWindowSize, write.
What calls handleOutboundMessage()?
handleOutboundMessage() is called by 1 function(s): write.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free