SignalR and SelfHost in F #

I think this will be a quick answer, but I could not find the right answer for today. I am trying to create an F # SignalR Self-Host application (I have completed this tutorial http://www.asp.net/signalr/overview/signalr-20/getting-started-with-signalr-20/tutorial-signalr-20-self -host )

As a result, my application does not display signalr / hubs on my localhost, there is no error message (only from the JavaScript file if it does not find the client).

namespace Program open Owin open Dynamic open Microsoft.AspNet.SignalR open Microsoft.AspNet.SignalR.Hubs open Microsoft.Owin.Hosting open Microsoft.Owin.Cors open System open System.Diagnostics type MyHub = inherit Hub member x.Send (name : string) (message : string) = base.Clients.All?addMessage name message type MyWebStartUp() = member x.Configuration (app :IAppBuilder) = app.UseCors CorsOptions.AllowAll |> ignore app.MapSignalR() |> ignore () module Starter = [<EntryPoint>] let main argv = let hostUrl = "http://localhost:8085" let disposable = WebApp.Start<MyWebStartUp>(hostUrl) Console.WriteLine("Server running on "+ hostUrl) Console.ReadLine() |> ignore disposable.Dispose() 0 // return an integer exit code 

At first I created a C # application and it works fine, I assume that my F # code is wrong, but I cannot find this error. For reference, the entire project is presented here: https://github.com/MartinBodocky/SignalRFSharp

+7
f # owin signalr
source share
1 answer

When you overload Start actions, you don’t need to create an entire type just for the initial configuration. You should also use use instead of manual deletion.

  let startup (a:IAppBuilder) = a.UseCors(CorsOptions.AllowAll) |> ignore a.MapSignalR() |> ignore use app = WebApp.Start(hostUrl, startup) 

But in order to make the code more pleasant, there is a problem with your hub code, because the dynamic module you called can only call a method with one argument, use FSharp.Interop.Dynamic (in nuget) for a reliable DLR statement ? .

 open EkonBenefits.FSharp.Dynamic type MyHub() = inherit Hub() member this.Send (name : string) (message : string) = this.Clients.All?addMessage(name,message) |> ignore 
+6
source share

All Articles