microsoft/teams.net

Public

mirrored fromhttps://github.com/microsoft/teams.netAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
samples/migration-bot

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

core/src/Microsoft.Teams.Bot.Core/ITurnMiddleWare.cs

34lines · modecode

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4using Microsoft.Teams.Bot.Core.Schema;
5
6namespace Microsoft.Teams.Bot.Core;
7
8/// <summary>
9/// Represents a delegate that invokes the next middleware component in the pipeline asynchronously.
10/// </summary>
11/// <remarks>This delegate is typically used in middleware scenarios to advance the request processing pipeline.
12/// The cancellation token should be observed to support cooperative cancellation.</remarks>
13/// <param name="cancellationToken">A cancellation token that can be used to cancel the asynchronous operation.</param>
14/// <returns>A task that represents the completion of the middleware invocation.</returns>
15public delegate Task NextTurn(CancellationToken cancellationToken);
16
17/// <summary>
18/// Defines a middleware component that can process or modify activities during a bot turn.
19/// </summary>
20/// <remarks>Implement this interface to add custom logic before or after the bot processes an activity.
21/// Middleware can perform tasks such as logging, authentication, or altering activities. Multiple middleware components
22/// can be chained together; each should call the nextTurn delegate to continue the pipeline.</remarks>
23public interface ITurnMiddleware
24{
25 /// <summary>
26 /// Triggers the middleware to process an activity during a bot turn.
27 /// </summary>
28 /// <param name="botApplication"></param>
29 /// <param name="activity"></param>
30 /// <param name="nextTurn"></param>
31 /// <param name="cancellationToken"></param>
32 /// <returns></returns>
33 Task OnTurnAsync(BotApplication botApplication, CoreActivity activity, NextTurn nextTurn, CancellationToken cancellationToken = default);
34}
35