Startup.cs中
//這個和發布通知無關吧?
app.UseEndpoints(endpoints =>
{
endpoints.MapHub<MessageHub>("/MessageHub");
});
領域層后端發布代碼
public class NotificationAppService: BusinessAssistantAppServiceBase,INotificationAppService, ITransientDependency
{
private readonly INotificationPublisher _notiticationPublisher;
public NotificationAppService(INotificationPublisher notificationPublisher)
{
_notiticationPublisher = notificationPublisher;
}
//發送常規通知給用戶
public async Task Publish_SentFrendshipRequest(string senderUserName, string friendshipMessage)
{
await _notiticationPublisher.PublishAsync("SentFrendshipRequest",
new SentFrendshipRequestNotificationData(senderUserName, friendshipMessage),
userIds: new[] { new Abp.UserIdentifier(null, 3), new Abp.UserIdentifier(1, 2), new Abp.UserIdentifier(1, 1) }, severity: NotificationSeverity.Success);
}
}
前端Vue監聽代碼 main.vue
init () {
util.abp.event.on('abp.notifications.received', function (userNotification) {
console.log(userNotification);
});
}
后端發布通知,前端abp.event.on監聽的全域事件abp.notifications.received并不會進入,不知道問題出在哪,請指點一下,謝謝。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/251261.html
標籤:ASP.NET
上一篇:求教:C#監聽掃碼槍,決議二維碼
