Skip to content

Commit

Permalink
Merge pull request #35 from judah4/more-web-api-improvements
Browse files Browse the repository at this point in the history
More web api improvements
  • Loading branch information
judah4 authored Nov 2, 2022
2 parents 98d92bc + 3cdb781 commit 5310a02
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 26 deletions.
44 changes: 18 additions & 26 deletions Mmo Game Framework/MainServer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;

namespace MmoGameFramework
{
Expand All @@ -31,21 +32,7 @@ static async Task Main(string[] args)
//var metricServer = new KestrelMetricServer(port: 1234);
//metricServer.Start();

IHost host = Host.CreateDefaultBuilder(args)
.ConfigureLogging(builder =>
{
builder.AddSimpleConsole(options =>
{
options.IncludeScopes = true;
options.SingleLine = true;
options.TimestampFormat = "hh:mm:ss ";
});
})
.ConfigureServices(x =>
{
x.AddSingleton<OrchestrationService>();
})
.Build();
IHost host = BuildHost(args);


_logger = host.Services.GetRequiredService<ILogger<Program>>();
Expand Down Expand Up @@ -124,8 +111,6 @@ static async Task Main(string[] args)
}, false, host.Services.GetRequiredService<ILogger<MmoServer>>(), configuration);
workerServer.Start();

StartAPI();

_logger.LogInformation("DragonGF is ready.");


Expand All @@ -137,23 +122,30 @@ static async Task Main(string[] args)
//metricServer.Stop();
}

private static async void StartAPI()


private static WebApplication BuildHost(string[] args)
{
_logger.LogInformation("Starting Console API");

//
var builder = WebApplication.CreateBuilder();
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.UseUrls("http://*:3000");
builder.Logging.AddSimpleConsole(options =>
{
options.IncludeScopes = true;
options.SingleLine = true;
options.TimestampFormat = "hh:mm:ss ";
});

builder.Services.AddSingleton<OrchestrationService>();

//
builder.Services.AddControllers();

var app = builder.Build();
// app.UseHttpsRedirection();

//app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();

await app.RunAsync("http://localhost:3000");
return app;
}

public static MmoServer GetServer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"profiles": {
"MainServer": {
"commandName": "Project",
"applicationUrl": "http://localhost:3000",
"environmentVariables": {
"DOTNET_ENVIRONMENT": "Development"
//"AGONES_SDK_GRPC_HOST": "192.168.4.241"
Expand Down

0 comments on commit 5310a02

Please sign in to comment.