microsoft/teams.net

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
3ddf9fa76ec1801a0e3ca312c6d9855879571ac1

Branches

Tags

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

Clone

HTTPS

Download ZIP

Libraries/Microsoft.Teams.Apps.Testing/Plugins/TestPlugin.Stream.cs

64lines · modecode

1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT License.
3
4
5using Microsoft.Teams.Api.Activities;
6using Microsoft.Teams.Api.Entities;
7using Microsoft.Teams.Apps.Plugins;
8
9namespace Microsoft.Teams.Apps.Testing.Plugins;
10
11public partial class TestPlugin
12{
13 /// <summary>
14 /// a test implementation of an IStreamer
15 /// </summary>
16 public class Stream : IStreamer
17 {
18 public bool Closed { get; internal set; }
19 public int Count { get; internal set; }
20 public int Sequence { get; internal set; }
21
22 public event IStreamer.OnChunkHandler OnChunk;
23
24 protected MessageActivity? _activity;
25
26 public void Emit(MessageActivity activity)
27 {
28 if (_activity is null)
29 {
30 _activity = activity;
31 }
32
33 _activity.Merge(activity);
34 }
35
36 public void Emit(TypingActivity activity)
37 {
38 if (_activity is null) return;
39 _activity.Merge(activity);
40 }
41
42 public void Emit(string text)
43 {
44 Emit(new MessageActivity(text));
45 }
46
47 public void Update(string text)
48 {
49 Emit(new TypingActivity(text)
50 {
51 ChannelData = new()
52 {
53 StreamType = StreamType.Informative
54 }
55 });
56 }
57
58 public Task<MessageActivity?> Close(CancellationToken cancellationToken = default)
59 {
60 Closed = true;
61 return Task.FromResult(_activity);
62 }
63 }
64}