Prerequisite:

Before implementing below project developers must have a knowledge of Orchard Core CMS.

To setup the Orchard CMS follow the below step:

§ Get basics information of OrchardCore CMS.Click Here

§ Get basics details of Orchard Core CMS Multi-tenant website.Click Here.

§ To install step wise Orchard Core CMS Click Here

Download the latest Orchard Core CMS from GitHub. To download the project.Click Here

Implement the below steps to execute the project:

1. Add reference of Microsoft.AspNet.SignalR Version="2.4.1"  in OrchardCore.Cms.Web

2. Add below code in Startup.cs of OrchardCore.Cms.Web under ConfigureServices method.

services.AddSignalR();

3. Add lib/signalr/signalr.js in wwwroot folder.

4. Create class as MyDemoHub. Inherit Hub.

public class MyDemoHub: Hub
    {
        public async Task SendMessage(string message)
        {
            await Clients.All.SendAsync("ReceiveMessage", message);
        }
    }

5. Add below code in Startup.cs of OrchardCore.Cms.Web under Configure method.

app.UseSignalR(routes =>
    {
        routes.MapHub("/myDemoHub");
    });

6. Suppose you have 2 tenants say tenantA and tenantB. You need to send a message from a module of tenantA to module of tenantB.

7. Add lib/signalr/signalr.js to wwwroot/tenantA and wwwroot/tenantB

Microsoft.AspNet.SignalR Version="2.4.1"
Microsoft.AspNet.SignalR.Client Version="2.4.1"
Microsoft.AspNet.SignalR.JS Version="2.4.1"

9. Add below code to view page of caller module

<script src="~/lib/signalr/signalr.js" type="text/javascript"></script>

<script type="text/javascript">

    "use strict";

    var connection = new signalR.HubConnectionBuilder().withUrl("https://localhost:44300/myDemoHub").build();

    connection.start().then(function () {

    }).catch(function (err) {

        return console.error(err.toString());

    });

    function sendMessage(message) {

        connection.invoke("SendMessage", message).catch(function (err) {

            return console.error(err.toString());

        });

    }

</script>

10. Add below code to view page of receiver module

<script src="~/lib/signalr/signalr.js" type="text/javascript"></script>

<script type="text/javascript">

    "use strict";

    var connection = new signalR.HubConnectionBuilder().withUrl("https://localhost:44300/myDemoHub").build();


    connection.on("ReceiveMessage", function (message) {

        console.log(message);

    });


    connection.start().then(function () {

    }).catch(function (err) {

        return console.error(err.toString());

    });

</script>

Words from our clients

 

Tell Us About Your Project

We’ve done lot’s of work, Let’s Check some from here