Building interactive console app with Web SDK

300 Views Asked by At

I'm going my first steps with .NET Core 3.1 by trying to build an agent/client for the Hyperledger Indy project. They provide a dotnet framework.

The used SDK is Microsoft.NET.Sdk.Web.

Heres my simple application:

Program.cs

using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;

namespace issuer
{
    class Program
    {
        static void Main(string[] args)
        {
            System.Console.WriteLine("====== Start ======"); // Printed to console
            CreateHostBuilder(args).Build().Run();

            var input = System.Console.ReadKey(); // Never reached
            System.Console.Write(" --- You pressed " + input.Key.ToString());
        }

        public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder.UseStartup<Startup>();
                });
    }
}

And Startup.cs:

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace issuer
{
    class Startup
    {
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddAriesFramework(builder =>
            {
                builder.RegisterAgent(options =>
                {
                    options.EndpointUri = "http://localhost:5000";
                    // ...
                });
            });
        }

        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseRouting();
            app.UseAriesFramework();
        }
    }
}

When I start it, I have a passive application listening on localhost:5000 for incoming requests from other clients.

What I want to achieve is an interactive console (instead of a web frontend) to actively initiate communication with other clients. I think a good first step would be to get a Console.ReadKey() after everything has been setup.

Is that even possible?

0

There are 0 best solutions below