2024-10-30 11:53:37 -07:00
|
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
// Program.cs
|
2025-01-28 17:13:36 -05:00
|
|
|
|
2024-12-12 19:43:26 -08:00
|
|
|
using Microsoft.AutoGen.Contracts;
|
2024-12-13 11:55:43 -08:00
|
|
|
using Microsoft.AutoGen.Core;
|
2025-01-28 17:13:36 -05:00
|
|
|
using Samples;
|
2024-11-01 15:43:20 -07:00
|
|
|
|
2025-01-28 17:13:36 -05:00
|
|
|
// Set up app builder for in-process runtime, allow message delivery to self, and add the Hello agent
|
|
|
|
AgentsAppBuilder appBuilder = new AgentsAppBuilder()
|
|
|
|
.UseInProcessRuntime(deliverToSelf: true)
|
|
|
|
.AddAgent<HelloAgent>("HelloAgent");
|
|
|
|
var app = await appBuilder.BuildAsync(); // Build the app
|
|
|
|
// Create a custom message type from proto and define message
|
|
|
|
NewMessageReceived message = new NewMessageReceived { Message = "Hello World!" };
|
|
|
|
await app.PublishMessageAsync(message, new TopicId("HelloTopic")); // Publish custom message (handler has been set in HelloAgent)
|
|
|
|
await app.WaitForShutdownAsync(); // Wait for shutdown from agent
|