-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.fs
48 lines (42 loc) · 1.69 KB
/
Program.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
open Giraffe
open System.IO
open Microsoft.AspNetCore.Hosting
open Microsoft.AspNetCore.Builder
open Microsoft.AspNetCore.SignalR
open Microsoft.Extensions.DependencyInjection
let webApp =
choose [ route "/about" >=> text "Tutorial F# and SignalR : diegobassay@gmail.com" ]
type InterfaceClientOperations =
abstract member ReceiveCoordenates :int * int * bool -> System.Threading.Tasks.Task
type DrawBoardHub () =
inherit Hub<InterfaceClientOperations> ()
// Passando mensagem para todos os clientes
member this.SendCoordenates (x: int, y: int, isMousePressed: bool) =
printf "Enviando coordenadas %i %i para o cliente!\n" x y
this.Clients.All.ReceiveCoordenates(x, y, isMousePressed)
type Startup() =
member __.ConfigureServices (services : IServiceCollection) =
// Registrando serviços com as dependências do SignalR
services.AddSignalR() |> ignore
// Registrando serviços com as dependências do Giraffe
services.AddGiraffe() |> ignore
member __.Configure (app : IApplicationBuilder) =
app.UseDefaultFiles() |> ignore
app.UseStaticFiles() |> ignore
app.UseSignalR(fun routes ->
routes.MapHub<DrawBoardHub>(Microsoft.AspNetCore.Http.PathString("/drawBoardHub"))
) |> ignore
app.UseGiraffe(webApp)
[<EntryPoint>]
let main _ =
let contentRoot = Directory.GetCurrentDirectory()
let webRoot = Path.Combine(contentRoot, "web")
WebHostBuilder()
.UseKestrel()
.UseContentRoot(contentRoot)
.UseIISIntegration()
.UseWebRoot(webRoot)
.UseStartup<Startup>()
.Build()
.Run()
0