Hi, I am riddling for some days now about how to relaize a simple matter: Some user updates an entity whilst another user is just viewing this entity in some way (eg. list view). The backend should now notify in that special case (not all places) ping the GUI so it can requery the backend and show an updated list.
I have tried at first to do my very own SignalR Hub for that. Somehow works but was not satisfying. And seems to look untidy with existing SignalR hubs. The topic about extending the AbpCommonHup by the way is badly documented and it is not clear, whether this is a feasable or even recommended way.
Then I came across the notification system and thought, this could just give me one notification as a by product. However my TS-code never gets called. What am I doing wrong?
What am I trying?
I created this transiend class that some code calls to notify the GUI (works until it calls the Publish (tried both Async and non-Async):
public class EntityUpdateNotifyer: ITransientDependency
{
private readonly INotificationPublisher \_notificationPublisher;
public EntityUpdateNotifyer(INotificationPublisher notificationPublisher)
: base()
{
_notificationPublisher = notificationPublisher;
AbpSession = NullAbpSession.Instance;
}
public IAbpSession AbpSession { get; set; }
public async Task NotifyClients(Type entiType, object id)
{
UserIdentifier uid = AbpSession.ToUserIdentifier();
var data = new NotificationData();
this._notificationPublisher.Publish("test.note.foobar", data, new EntityIdentifier(entiType, id), NotificationSeverity.Info,
null, null, null);
return;
}
}
For the client side (angular+TS) I extended a classical list view like that. I am not seeing the event caused alert. The others yes. So ngOnInit gets called.
...
constructor(
injector: Injector,
private _appSessService: AppSessionService,
private _objekteServiceProxy: ObjekteServiceProxy,
private _notifyService: NotifyService,
private _tokenAuth: TokenAuthServiceProxy,
private _activatedRoute: ActivatedRoute,
private _fileDownloadService: FileDownloadService
) {
super(injector);
this._blaServiceProxy.getDistinctBla()
.subscribe(result => { this.distinctBlaList = result.concat(""); });
}
ngOnInit(): void {
alert("nginit");
abp.event.on('abp.notifications.received', function (userNotification) {
alert("event a" + userNotification);
});
abp.event.on('test.note.foobar', function (userNotification) {
alert("event foobar" + userNotification);
});
}
...
I tried to subscribe to the somehow mentioned abp.notifications.received
event ID plus my own ID (this does not quite read out of the documentation).
But my event alerts never appear.
It must be just a detail that I am missing. Please show me the detail.