first commit
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
using F9WebAiTest.Application.Dtos.Notice;
|
||||
|
||||
namespace F9WebAiTest.Application.Services.Notice;
|
||||
|
||||
/// <summary>
|
||||
/// 消息实时推送器(抽象)。
|
||||
/// 定义在应用层、实现在 Api 层(依赖 SignalR 的 IHubContext 与在线登记表),
|
||||
/// 避免应用层反向依赖表示层,同时让"创建消息即推送"这一动作可以写在命令处理器里。
|
||||
/// </summary>
|
||||
public interface INotificationPusher
|
||||
{
|
||||
/// <summary>
|
||||
/// 判断用户当前是否在线。
|
||||
/// 判定依据:该用户在 SignalR Hub 上是否有活动连接(由 Hub 连接/断开时登记的内存表得出)。
|
||||
/// </summary>
|
||||
bool IsOnline(long userId);
|
||||
|
||||
/// <summary>
|
||||
/// 推送新消息给指定用户。
|
||||
/// 返回 true 表示已推送给其在线连接;返回 false 表示用户离线(未推送,消息已落库,上线后从"我的消息"拉取)。
|
||||
/// </summary>
|
||||
Task<bool> PushNewMessageAsync(long userId, NotificationMessageDto message, CancellationToken ct = default);
|
||||
|
||||
/// <summary>推送未读统计,用于消息角标实时同步(用户离线时无需推送)。</summary>
|
||||
Task PushUnreadCountAsync(long userId, int unreadCount, int todoCount, CancellationToken ct = default);
|
||||
}
|
||||
Reference in New Issue
Block a user