//这个和发布通知无关吧?
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并不会进入,不知道问题出在哪,请指点一下,谢谢。