I think this will be quick answer, but I couldn't find the right answer during today. I trying create F# SignalR Self-Host application ( I followed this tutorial http://www.asp.net/signalr/overview/signalr-20/getting-started-with-signalr-20/tutorial-signalr-20-self-host)
The outcome is my application don't map signalr/hubs on my localhost, there is no error message (only from JavaScript file when it doesn't find 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
I created C# application first and it does work perfectly, I assume my F# code is not right, but I cannot find that bug. For reference here is whole project: https://github.com/MartinBodocky/SignalRFSharp
With the action overload of Start
, you don't have to make a whole type just for the start up configuration. Also you should definitely use use
instead of manually disposing.
let startup (a:IAppBuilder) =
a.UseCors(CorsOptions.AllowAll) |> ignore
a.MapSignalR() |> ignore
use app = WebApp.Start(hostUrl, startup)
But that's just to make the code nicer, there is a problem with your hub code because the Dynamic module you brought can only invoke a method with one argument, use FSharp.Interop.Dynamic (in nuget) for a robust DLR ?
Operator.
open EkonBenefits.FSharp.Dynamic
type MyHub() =
inherit Hub()
member this.Send (name : string) (message : string) =
this.Clients.All?addMessage(name,message) |> ignore
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With