Base solution for your next web application
Open Closed

Integratate Notification system into existing project #855


User avatar
0
paddyfink created

Hi halil,

I try to integrate the notification system into my existing explication. I have one problem : nothing get fired on the client side. this function is never called :

//Register to get notifications
    commonHub.client.getNotification = function (notification) {
        abp.event.trigger('abp.notifications.received', notification);
    };

If I execute the directly this command on my browser console, I can catch the event: abp.event.trigger('abp.notifications.received', {message: 'something'});

So the problem is coming form commonhub. And also I noticed something weirg on the log, I get registered, but the userid and tenantid are null : A client is connected: {"ConnectionId":"671a0694-5b35-4ac3-90b1-a9c4cc831cdd","IpAddress":"::1","TenantId":null,"UserId":null,"ConnectTime":"2016-03-07T13:40:25.2281687-05:00","Properties":{}} and again to information are supposed to be fill in the class AbpCommonHub

Maybe I missed something in the configuration. There is something to do for the class abpcommonhub to work correctly on a existing project? I've already add [DependsOn(typeof(AbpWebSignalRModule))] on my web module.


5 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Which version of ABP is referenced in your project ?

  • User Avatar
    0
    paddyfink created

    It's the 0.8.2

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    In the owin startup class "Startup.cs", SignalR mapping must be placed just before HangFire configuration at the end of Configuration method.

    ....
        app.MapSignalR();
    
        app.UseHangfireDashboard(); //Should be removed if not using Hangfire as background job manager
    }
    

    Let us know if it does not work.

  • User Avatar
    0
    paddyfink created

    Hello Thanks. it's better. Now I got the right information : A client is connected: {"ConnectionId":"392af956-606e-4187-b1e6-8adb173dd36e","IpAddress":"::1","TenantId":1,"UserId":2,"ConnectTime":"2016-03-09T16:42:08.5693186-05:00","Properties":{}}

    I made a little test, I publish three notification like this :

    await _notificationPublisher.PublishAsync(AppNotificationNames.NewRequest, notificationData, tenantIds: new int?[] { request.TenantId });
                await _notificationPublisher.PublishAsync(AppNotificationNames.NewRequest, notificationData, userIds: new long[] { 2 });
                await _notificationPublisher.PublishAsync(AppNotificationNames.NewRequest, notificationData);
    

    I only received a notification when I specify a user. I expected :

    • a notification to be received by every users if we don't specify a tenant nor a user
    • a notification to be received by every users of a tenant if we specify just the tenant id
    • a notfication to be received by only a users if we specidfy the user

    All those without subscribing to anything. Is not supposed to work like that?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    • a notification to be received by every users if we don't specify a tenant nor a user

    This is not right. This notification will be sent to subscribed users of current tenant.

    The other two cases are correct but notifications are sent to subscribed users only.

    You can find more about notifications here if you haven't read it yet. <a class="postlink" href="http://aspnetboilerplate.com/Pages/Documents/Notification-System">http://aspnetboilerplate.com/Pages/Docu ... ion-System</a>