// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using Microsoft.Teams.Core.Schema;
namespace Microsoft.Teams.Core;
///
/// Represents a delegate that invokes the next middleware component in the pipeline asynchronously.
///
/// This delegate is typically used in middleware scenarios to advance the request processing pipeline.
/// The cancellation token should be observed to support cooperative cancellation.
/// A cancellation token that can be used to cancel the asynchronous operation.
/// A task that represents the completion of the middleware invocation.
public delegate Task NextTurn(CancellationToken cancellationToken);
///
/// Defines a middleware component that can process or modify activities during a bot turn.
///
/// Implement this interface to add custom logic before or after the bot processes an activity.
/// Middleware can perform tasks such as logging, authentication, or altering activities. Multiple middleware components
/// can be chained together; each should call the nextTurn delegate to continue the pipeline.
public interface ITurnMiddleware
{
///
/// Triggers the middleware to process an activity during a bot turn.
///
/// The bot application processing the current turn.
/// The incoming activity to process.
/// A delegate that invokes the next middleware in the pipeline. Call this to continue processing.
/// A cancellation token that can be used to cancel the operation.
/// A task that represents the asynchronous middleware execution.
Task OnTurnAsync(BotApplication botApplication, CoreActivity activity, NextTurn nextTurn, CancellationToken cancellationToken = default);
}