SignalR chat module in Orchard CMS

I am creating an instant chat module for a gardening project that I am working on. I would like to use SignalR to enable chat, however I am having difficulty with this:

<script src="@Url.Content("~/signalr/hubs")" type="text/javascript"></script> 

I get 404 error with everything I try. I have RAMFAR in webconfig, I tried to rewrite the url in IIS. I hope this is something terribly simple that my familiar brain cannot see. I don’t even know for sure that SignalR works with Orchard, I suspected that some difficulties would arise, although

+4
source share
2 answers

This is much more complicated than @mdm described ... SignalR uses a custom HttpModule that handles hubs . Unfortunately, due to the dynamic loading of modular assemblies, it is not possible to connect this HttpModule from a module without changing the Orchard kernel.

Fortunately, I managed to figure it out and make a live demo with Orchard and SignalR , playing together well! The execution of this work was rather complicated and included the exception of the HttpModule in favor of implementing a custom route. I will pull the module into the Orchard gallery after performing the necessary cleaning and publish the update here.

UPDATE:. The module is almost complete. There have been many changes to the SignalR library since I started using them that way. In addition, there is one small change in the Orchard core (session processing) that I need to click before publishing the module.

UPDATE 2: SignalR now uses Owin, so it’s much easier to connect everything. The Orchard module is available here . You can also grab the latest code from BitBucket. By the way, I highly recommend using the code from the Orchard 1.x branch to develop SignalR due to changes in database transaction processing.

+6
source

What is the url that is displayed on the page? What url do you expect from it?

Usually you put SignalR code in Scripts/signalr and reference scripts with the following at the top of your view:

 @{ Script.Include("signalr/script.js"); } 

Or you could implement IResourceManifestProvider in your module (Orchard.jQuery has a fantastic example of this, or see here ), and then link to your scripts using Script.Require :

 @{ Script.Require("SignalR_Hubs"); } 
0
source

Source: https://habr.com/ru/post/1393957/


All Articles