本文介绍了实时通知未发送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在ASP.NET Boilerplate中显示实时通知,但未发送。

 公共替代异步Task< MessagesDto> Create(MessagesCreateDto input)
{
var MessagesCore = ObjectMapper.Map< MessagesCore>(输入);
MessagesCore.UserId = Convert.ToInt32(AbpSession.UserId);
MessagesCore.CreationId = Convert.ToInt32(AbpSession.UserId);
MessagesCore.FromUserId = Convert.ToInt32(AbpSession.UserId);
MessagesCore.CreationTime = DateTime.Now;
MessagesCore.LastModificationId = Convert.ToInt32(AbpSession.UserId);
MessagesCore.LastModificationTime = DateTime.Now;

_stateRepository.Insert(MessagesCore);
CurrentUnitOfWork.SaveChanges();

UserIdentifier标识符= new UserIdentifier(1,input.ToUserId);
等待_notificationSubscriptionManager.SubscribeAsync(new UserIdentifier(1,input.ToUserId), NewMessage);
等待_notificationPublisher.PublishAsync( NewMessage,新的SentMessageNotificationData( Test,新消息),userIds:new [] {标识符});

return MapToEntityDto(MessagesCore);
}

SentMessage 通知数据类:

  [可序列化] 
公共类SentMessageNotificationData:NotificationData
{
公共字符串SenderUserName {get;组; }

公用字串FriendshipMessage {get;组; }

public SentMessageNotificationData(字符串senderUserName,字符串friendshipMessage)
{
SenderUserName = senderUserName;
FriendshipMessage =友谊消息;
}
}

数据存储在通知表中,但没有通知消息在客户端显示。





更新2



您可以现在 v3.4.1 带有AspNetCore的模板.SignalR预览。


I am trying to display realtime notification in ASP.NET Boilerplate, but it is not sent.

public override async Task<MessagesDto> Create(MessagesCreateDto input)
{
    var MessagesCore = ObjectMapper.Map<MessagesCore>(input);
    MessagesCore.UserId = Convert.ToInt32(AbpSession.UserId);
    MessagesCore.CreationId = Convert.ToInt32(AbpSession.UserId);
    MessagesCore.FromUserId = Convert.ToInt32(AbpSession.UserId);
    MessagesCore.CreationTime = DateTime.Now;
    MessagesCore.LastModificationId = Convert.ToInt32(AbpSession.UserId);
    MessagesCore.LastModificationTime = DateTime.Now;

    _stateRepository.Insert(MessagesCore);
    CurrentUnitOfWork.SaveChanges();

    UserIdentifier identifier = new UserIdentifier(1,input.ToUserId);
    await _notificationSubscriptionManager.SubscribeAsync(new UserIdentifier(1, input.ToUserId), "NewMessage");
    await _notificationPublisher.PublishAsync("NewMessage", new SentMessageNotificationData("Test", "New Message"), userIds: new[] { identifier });

    return MapToEntityDto(MessagesCore);
}

SentMessage notification data class:

[Serializable]
public class SentMessageNotificationData : NotificationData
{
    public string SenderUserName { get; set; }

    public string FriendshipMessage { get; set; }

    public SentMessageNotificationData(string senderUserName, string friendshipMessage)
    {
        SenderUserName = senderUserName;
        FriendshipMessage = friendshipMessage;
    }
}

Data is stored in notification table, but no notification message is displaying in client side.

SignalR code in

Update 2

You can now download v3.4.1 of the template with the AspNetCore.SignalR preview.

这篇关于实时通知未发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 19:05