26 lines
700 B
C#
26 lines
700 B
C#
|
|
// 1. 定义接口
|
||
|
|
using System.Threading.Channels;
|
||
|
|
namespace Admin.NET.Core.Ai.Interface;
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// SSE通道管理接口
|
||
|
|
/// </summary>
|
||
|
|
public interface ISseChannelManager
|
||
|
|
{
|
||
|
|
/// <summary>
|
||
|
|
/// 注册
|
||
|
|
/// </summary>
|
||
|
|
ChannelReader<string> Register(long userId);
|
||
|
|
/// <summary>
|
||
|
|
/// 注销
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="userId"></param>
|
||
|
|
void Unregister(long userId);
|
||
|
|
/// <summary>
|
||
|
|
/// 发送消息
|
||
|
|
/// </summary>
|
||
|
|
/// <param name="userId"></param>
|
||
|
|
/// <param name="message"></param>
|
||
|
|
/// <param name="cancellationToken"></param>
|
||
|
|
Task SendMessageAsync(long userId, string message, CancellationToken cancellationToken = default);
|
||
|
|
}
|