Files
swift-nio-http2/Sources/NIOHTTP2/HTTP2StreamDelegate.swift
T
Rick Newton-Rogers 795c1d4a48 Expose a functional NIOHTTP2StreamDelegate (#382)
Motivation:

Allow handlers in the pipeline to be notified when an HTTP2 stream is created or
closed.

Modifications:

Store an instance of a `NIOHTTP2StreamDelegate` on the `NIOHTTP2Handler`
and `InlineStreamMultiplexer` so that it may be called when streams are
created or closed.

Added tests.

Result:

`NIOHTTP2Handler`s init'd with a `streamDelegate` will now call into
that delegate's `streamCreated` and `streamClosed` functions.
2023-03-31 09:14:18 +01:00

27 lines
967 B
Swift

//===----------------------------------------------------------------------===//
//
// This source file is part of the SwiftNIO open source project
//
// Copyright (c) 2023 Apple Inc. and the SwiftNIO project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of SwiftNIO project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import NIOCore
/// A delegate which can be used with the ``NIOHTTP2Handler`` and its multiplexer.
///
/// Delegates are called when the multiplexer creates or closes HTTP/2 streams.
public protocol NIOHTTP2StreamDelegate: Sendable {
/// A new HTTP/2 stream was created with the given ID.
func streamCreated(_ id: HTTP2StreamID, channel: Channel)
/// An HTTP/2 stream with the given ID was closed.
func streamClosed(_ id: HTTP2StreamID, channel: Channel)
}