Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "pankajmathur"

I created a sample SignalR project (I am not talking about ABP or Module Zero Here). Normal ASP.Net Core Application.

My startup class has following code.

app.Map("/signalr", map => { map.UseCors(CorsOptions.AllowAll); var hubConfiguration = new HubConfiguration{}; map.RunSignalR(hubConfiguration); });

Now there is another application (say windows application) who wanted to connect to my application using signalR. So the windows application use the following code to connect to my Hub hubConnection = new HubConnection("http://localhost:18444/signalr/hubs");

Please see the URL of Hub in the above code. When I browse the above URL (<a class="postlink" href="http://localhost:18444/signalr/hubs">http://localhost:18444/signalr/hubs</a>), it gives me following output...

/*!

  • ASP.NET SignalR JavaScript Library v2.2.2
  • <a class="postlink" href="http://signalr.net/">http://signalr.net/</a>
  • Copyright (c) .NET Foundation. All rights reserved.
  • Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

*/

/// <reference path="....\SignalR.Client.JS\Scripts\jquery-1.6.4.js" /> /// <reference path="jquery.signalR.js" /> (function ($, window, undefined) { /// <param name="$" type="jQuery" /> "use strict";

if (typeof ($.signalR) !== "function") {
    throw new Error("SignalR: SignalR is not loaded. Please ensure jquery.signalR-x.js is referenced before ~/signalr/js.");
}

var signalR = $.signalR;

function makeProxyCallback(hub, callback) {
    return function () {
        // Call the client hub method
        callback.apply(hub, $.makeArray(arguments));
    };
}

function registerHubProxies(instance, shouldSubscribe) {
    var key, hub, memberKey, memberValue, subscriptionMethod;

    for (key in instance) {
        if (instance.hasOwnProperty(key)) {
            hub = instance[key];

            if (!(hub.hubName)) {
                // Not a client hub
                continue;
            }

            if (shouldSubscribe) {
                // We want to subscribe to the hub events
                subscriptionMethod = hub.on;
            } else {
                // We want to unsubscribe from the hub events
                subscriptionMethod = hub.off;
            }

            // Loop through all members on the hub and find client hub functions to subscribe/unsubscribe
            for (memberKey in hub.client) {
                if (hub.client.hasOwnProperty(memberKey)) {
                    memberValue = hub.client[memberKey];

                    if (!$.isFunction(memberValue)) {
                        // Not a client hub function
                        continue;
                    }

                    subscriptionMethod.call(hub, memberKey, makeProxyCallback(hub, memberValue));
                }
            }
        }
    }
}

$.hubConnection.prototype.createHubProxies = function () {
    var proxies = {};
    this.starting(function () {
        // Register the hub proxies as subscribed
        // (instance, shouldSubscribe)
        registerHubProxies(proxies, true);

        this._registerSubscribedHubs();
    }).disconnected(function () {
        // Unsubscribe all hub proxies when we "disconnect".  This is to ensure that we do not re-add functional call backs.
        // (instance, shouldSubscribe)
        registerHubProxies(proxies, false);
    });

    proxies['myHub'] = this.createHubProxy('myHub'); 
    proxies['myHub'].client = { };
    proxies['myHub'].server = {
        broadCastToAllClients: function (whomToSend) {
            return proxies['myHub'].invoke.apply(proxies['myHub'], $.merge(["BroadCastToAllClients"], $.makeArray(arguments)));
         },

        connect: function (User) {
            return proxies['myHub'].invoke.apply(proxies['myHub'], $.merge(["Connect"], $.makeArray(arguments)));
         },

        sendToServer: function (msg) {
            return proxies['myHub'].invoke.apply(proxies['myHub'], $.merge(["SendToServer"], $.makeArray(arguments)));
         }
    };

    return proxies;
};

signalR.hub = $.hubConnection("/signalr", { useDefaultPath: false });
$.extend(signalR, signalR.hub.createHubProxies());

}(window.jQuery, window));

Question is What would be my hub URL in Module Zero project. My startup class has following code: app.UseSignalR(routes => { //routes.MapHub<AbpCommonHub>("/signalr"); routes.MapHub<iVend365Hub>("/signalr"); });

Appreciate your response.

Regards, Mahendra

could you please provide me a sample application that uses signalR to send and receive message from Client and Vice-versa....

Thanks...I did that...Now following the document <a class="postlink" href="https://aspnetboilerplate.com/Pages/Documents/SignalR-AspNetCore-Integration">https://aspnetboilerplate.com/Pages/Doc ... ntegration</a> at the following step..."Client-Side (jQuery)", I included below lines in my Area/Mpa/Views/Layout/_Layout.cshtml file....

<script src="~/lib/signalr-client/signalr.min.js"></script> <script src="~/lib/abp-web-resources/Abp/Framework/scripts/libs/abp.signalr-client.js"></script>

Now when I run any of my pages, it throws me following error:

abp.signalr-client.js:97 Uncaught TypeError: Cannot read property 'WebSockets' of undefined at startConnection (abp.signalr-client.js:97) at Object.abp.signalr.connect (abp.signalr-client.js:47) at abp.signalr-client.js:107 at abp.signalr-client.js:110

Please help...

Hi,

I have downloaded the Module Zero (5.4) having ABP (3.6.1) with MVC and JQuery Template project for .Net Core 2.0. I am following the document <a class="postlink" href="https://aspnetboilerplate.com/Pages/Documents/SignalR-AspNetCore-Integration">https://aspnetboilerplate.com/Pages/Doc ... ntegration</a> for implementing SignalR.

I installed the Nuget packet Abp.AspNetCore.SignalR in the .Web.Core Project. Then in the .Web.Mvc project, startup.cs file I wrote the first line as #define FEATURE_SIGNALR

Now the below line (after using statements )(these lines were already there in the project) throwing errors... #if FEATURE_SIGNALR using Owin; using Abp.Owin; using Microsoft.AspNet.SignalR; using Microsoft.AspNet.SignalR.Hubs; using Abp.AspNetZeroCore.Web.Owin; using Owin.Security.AesDataProtectorProvider; #endif

Also following line in Configure method of Startup.cs is not compiling. #if FEATURE_SIGNALR //Integrate to OWIN app.UseAppBuilder(ConfigureOwinServices); #endif

Also following line of code is not compiling....

#if FEATURE_SIGNALR private static void ConfigureOwinServices(IAppBuilder app) { GlobalHost.DependencyResolver.Register(typeof(IAssemblyLocator), () => new SignalRAssemblyLocator()); app.Properties["host.AppName"] = "iVend365";

        app.UseAbp();
        app.UseAesDataProtectorProvider();

        app.MapSignalR();
    }

#endif

Please help me what should I fix to proceed and complete the SignalR implementation.....

Regards, Mahendra

Answer

Is Abp.Owin 3.6.1 supports .NetCore 2.0 yet?

Because when I add the Package ABP.Owin, it restored using .Net Framework 4.6.1?

Question

Hi,

I am using

  1. ASPNetZero 4.5 (MVC with Jquery)
  2. ABP 3.6.1
  3. .Net Core 2.0

I was following this document to implement SignalR <a class="postlink" href="https://aspnetboilerplate.com/Pages/Documents/SignalR-AspNetCore-Integration">https://aspnetboilerplate.com/Pages/Doc ... ntegration</a>

Following the above document section "Client-Side (jQuery)", When I install the package "Abp.Web.Resources", it does not copy the following file "~/lib/abp-web-resources/Abp/Framework/scripts/libs/abp.signalr-client.js"

What I noticed: In the Web Project Dependencies, I see the attached error (See the attachment). The error message in the attachment is : "Package Abp.Web.Resources 3.6.1" was restored using '.NETPortable, version=v4.0, Profile=Profile259, .NetFramework, Version=4.6.1' instead of the project target '.NetCoreApp, Version=v2.0'. This package may not be fully compatible with your project.

My question is Can I even use the signalR in the project template that I have downloaded? If yes, what is the way to proceed?

Regards, Mahendra

Answer

Agree what you are saying....

but is there any alternate, so I will save my lots of time to refactor the code as per your suggestion....

Regards, Mahendra

Answer

Hi Aaron,

I got stuck again.... I have Linq Query, that returns me an anonymous entity. Now, when I try to map the above anonymous entity to one of my DTO (of course my anonymous entity does not have all the properties that the DTO has), I have to write following code before mapping it to my DTO.

Mapper.Initialize(cfg => cfg.CreateMissingTypeMaps = true);

Now this code is throwing following error..

Mapper already initialized. You must call Initialize once per application domain/process.

I tried commenting this code
//Mapper.Initialize(cfg => cfg.CreateMissingTypeMaps = true);

and instead tried writing the following code in CustomDtoMapper.cs configuration.CreateMissingTypeMaps = true;

But still the Automapper is throwing error of missing map while mapping the anonymous entity to DTO...

Please advise....

Answer

Thanks...Much appreciated....

Regards, Mahendra

Answer

Thanks aaron....it worked....Many thanks for the solution....

Can you please just clarify one more thing to me....

So now I am on ASPNetZero 4.5 with ABP 3.6.1...... My question is if I do not upgrade to ASPNetZero to 5.4, Can I still use SignalR....

Regards, Mahendra

Showing 31 to 40 of 123 entries