Session.send

Sends pending frames to the remote peer.

This function retrieves the highest prioritized frame from the outbound queue and sends it to the remote peer. It does this as many as possible until the user callback Connector.write returns ErrorCode.WOULDBLOCK or the outbound queue becomes empty.

This function calls several Connector functions which are passed when initializing the Session. Here is the simple time chart which tells when each callback is invoked:

1. Get the next frame to be sent from a priority sorted outbound queue.

2. Prepare transmission of the frame.

3. Connector.onFrameFailure may be invoked if the control frame cannot be sent because some preconditions are not met (e.g., request HEADERS cannot be sent after GOAWAY). This then aborts the following steps.

4. Connector.selectPaddingLength is invoked if the frame is HEADERS, PUSH_PROMISE or DATA.

5. If the frame is request HEADERS, the stream is opened here.

6. Connector.onFrameReady is invoked.

7. Connector.write is invoked one or more times to send the frame.

8. Connector.onFrameSent is invoked after all data is transmitted.

9. Connector.onStreamExit may be invoked if the transmission of the frame triggers closure of the stream, it is destroyed afterwards.

This function returns 0 if it succeeds, or one of the following negative error codes:

ErrorCode.CALLBACK_FAILURE The callback function failed.

class Session
send
()

Meta