Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Developing a Self-Hosted SignalR+NancyFx

I wrote a self-hosted SignalR app (a windows service). Now I want to add NancyFx to this app for handling the UI - a self-sufficient, drop-in web app without any external dependencies.

I know we can have a self-hosted SignalR app. Also we can have a self-hosted NancyFx app.

Now, how to combine these two in one app? Which one should host which one?

like image 426
Kaveh Shahbazian Avatar asked Oct 21 '13 16:10

Kaveh Shahbazian


1 Answers

Use Owin, it will make things easier. In terms of examples you can look at:

https://github.com/damianh/NancySignalrOwin

That's probably the easiest / best example.

Basically you want to create a startup file and specify a path for Nancy to use.

public partial class Startup
{
    public void Configuration(IAppBuilder app)
    {
        app.Map("/site", siteBuilder => siteBuilder.UseNancy())
           .MapSignalR();
    }
}

Then start your WebApplication normally in your program file or where ever you start it. And SignalR and Nancy will be picked up.

Edit: Map/MapPath come from Microsoft.Owin package.

like image 96
Phill Avatar answered Sep 30 '22 16:09

Phill