Skip to content

Commit

Permalink
still trying to get it to work all in one process.
Browse files Browse the repository at this point in the history
  • Loading branch information
rysweet committed Oct 8, 2024
1 parent ae326cc commit f85730d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
22 changes: 18 additions & 4 deletions dotnet/samples/Hello/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,34 @@
using Microsoft.AutoGen.Agents.Client;
using Microsoft.AutoGen.Agents.Runtime;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Server.Kestrel.Core;

var builder = Host.CreateApplicationBuilder(args);
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.ConfigureKestrel(serverOptions =>
{
serverOptions.ConfigureEndpointDefaults(lo => lo.Protocols = HttpProtocols.Http2);
serverOptions.ListenLocalhost(5001, listenOptions =>
{
listenOptions.Protocols = HttpProtocols.Http2;
listenOptions.UseHttps();
});
});
builder.AddAgentService();
builder.Services.AddHostedService<AgentWorkerRuntime>();
builder.Services.AddSingleton<AgentClient>();
builder.UseOrleans(siloBuilder =>
{
siloBuilder.UseLocalhostClustering(); ;
});
builder.AddAgentWorker("https://localhost:5000");
builder.Services.AddHostedService<AgentWorkerRuntime>();
builder.Services.AddSingleton<AgentClient>();
var agentBuilder = builder.AddAgentWorker("https://localhost:5001").AddAgent<HelloAgent>("HelloAgent");
var app = builder.Build();
app.MapAgentService();
await app.StartAsync();
AgentClient client = app.Services.GetRequiredService<AgentClient>();
app.Services.GetRequiredService<AgentWorkerRuntime>();

//send our hello message event via cloud events
var evt = new NewMessageReceived
{
Expand Down
8 changes: 8 additions & 0 deletions dotnet/samples/Hello/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ private async ValueTask RegisterAgentType(string type, Type agentType)
var events = agentType.GetInterfaces()
.Where(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IHandle<>))
.Select(i => i.GetGenericArguments().First().Name);
var state = agentType.BaseType?.GetGenericArguments().First();
//var state = agentType.BaseType?.GetGenericArguments().First();
var topicTypes = agentType.GetCustomAttributes<TopicSubscriptionAttribute>().Select(t => t.Topic);

await WriteChannelAsync(new Message
Expand Down

0 comments on commit f85730d

Please sign in to comment.