From a8760944a08519edc0f74a33c396d5a6053de5e9 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Sun, 4 Feb 2018 22:23:23 +0100 Subject: Initial version. --- HelloLib/HelloLib.fsproj | 19 +++++++++++++++++++ HelloLib/Library.fs | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 HelloLib/HelloLib.fsproj create mode 100644 HelloLib/Library.fs (limited to 'HelloLib') diff --git a/HelloLib/HelloLib.fsproj b/HelloLib/HelloLib.fsproj new file mode 100644 index 0000000..2ce9913 --- /dev/null +++ b/HelloLib/HelloLib.fsproj @@ -0,0 +1,19 @@ + + + netstandard2.0 + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/HelloLib/Library.fs b/HelloLib/Library.fs new file mode 100644 index 0000000..10897f3 --- /dev/null +++ b/HelloLib/Library.fs @@ -0,0 +1,32 @@ +namespace HelloLib + +open System.Threading.Tasks +open System +open Hopac +open Google.Protobuf +open Grpc.Core + +module Greeting = + let private Hello name = + printfn "Hello %s from F#!" name + + type private HelloSayerImpl () = + inherit HelloNet.Api.HelloSayer.HelloSayerBase() + + override this.SayHello(request: HelloNet.Api.HelloRequest, context : ServerCallContext) : Task = + Hello request.Greetee + new HelloNet.Api.HelloResponse() |> Hopac.Job.result |> Hopac.queueAsTask + + let Serve () = + let port = 10000 + let server = new Server() + + server.Services.Add(HelloNet.Api.HelloSayer.BindService(new HelloSayerImpl())) + server.Ports.Add(new ServerPort("localhost", port, ServerCredentials.Insecure)) |> ignore + server.Start() + + server + + let MakeClient () = + let channel = new Channel("127.0.0.1:10000", ChannelCredentials.Insecure) + new HelloNet.Api.HelloSayer.HelloSayerClient(channel) -- cgit v1.2.3