-
-
Notifications
You must be signed in to change notification settings - Fork 295
Expand file tree
/
Copy pathProgram.cs
More file actions
40 lines (34 loc) · 1.07 KB
/
Program.cs
File metadata and controls
40 lines (34 loc) · 1.07 KB
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
using System;
using System.Security.Cryptography.X509Certificates;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Proto;
using Proto.Remote;
using Proto.Remote.GrpcNet;
using static Proto.Remote.RemoteConfig;
using Common;
var certificate = new X509Certificate2("../localhost.pfx", "password");
var remoteConfig = BindToLocalhost(8000) with
{
UseHttps = true,
ConfigureKestrel = options =>
{
options.Protocols = HttpProtocols.Http2;
options.UseHttps(certificate);
}
};
var system = new ActorSystem().WithRemote(remoteConfig);
var props = Props.FromProducer(() => new GreeterActor());
system.Root.SpawnNamed(props, "greeter");
await system.Remote().StartAsync();
Console.WriteLine("Remote TLS server started. Press enter to exit.");
Console.ReadLine();
public class GreeterActor : IActor
{
public Task ReceiveAsync(IContext context)
=> context.Message switch
{
HelloRequest req => context.Respond(new HelloResponse($"Hello, {req.Name}!"))
.AsTask(),
_ => Task.CompletedTask
};
}