mirror of
https://github.com/SoDOff-Project/sodoff-mmo.git
synced 2025-10-11 16:28:50 -07:00
start api before listener starts, stop and dispose of it when it stops, add `HttpApiPort
` to config
This commit is contained in:
parent
75824931d3
commit
1566949913
@ -29,6 +29,7 @@ internal static class Configuration {
|
|||||||
internal sealed class ServerConfiguration {
|
internal sealed class ServerConfiguration {
|
||||||
public string ListenIP { get; set; } = string.Empty;
|
public string ListenIP { get; set; } = string.Empty;
|
||||||
public int Port { get; set; } = 9933;
|
public int Port { get; set; } = 9933;
|
||||||
|
public int HttpApiPort { get; set; } = 9934;
|
||||||
public string EventName { get; set; } = "ScoutAttack";
|
public string EventName { get; set; } = "ScoutAttack";
|
||||||
public int EventTimer { get; set; } = 30;
|
public int EventTimer { get; set; } = 30;
|
||||||
public int FirstEventTimer { get; set; } = 10;
|
public int FirstEventTimer { get; set; } = 10;
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using sodoffmmo.Core;
|
using sodoffmmo.API;
|
||||||
|
using sodoffmmo.Core;
|
||||||
using sodoffmmo.Data;
|
using sodoffmmo.Data;
|
||||||
using sodoffmmo.Management;
|
using sodoffmmo.Management;
|
||||||
using System;
|
using System;
|
||||||
@ -42,7 +43,14 @@ public class Server {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// start api before mmo listener is started
|
||||||
|
var apiBuilder = CreateApiBuilder().Build();
|
||||||
|
await apiBuilder.StartAsync();
|
||||||
await Listen(listener);
|
await Listen(listener);
|
||||||
|
|
||||||
|
// when listener thread exists, stop and dispose api
|
||||||
|
await apiBuilder.StopAsync();
|
||||||
|
apiBuilder.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task Listen(Socket listener) {
|
private async Task Listen(Socket listener) {
|
||||||
@ -97,4 +105,13 @@ public class Server {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static IHostBuilder CreateApiBuilder()
|
||||||
|
{
|
||||||
|
return Host.CreateDefaultBuilder().ConfigureWebHostDefaults(webHost =>
|
||||||
|
{
|
||||||
|
webHost.UseUrls($"http://*:{Configuration.ServerConfiguration.HttpApiPort}");
|
||||||
|
webHost.UseStartup<ApiStartup>();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,9 @@
|
|||||||
"// Port": "Listening port number for the MMO server",
|
"// Port": "Listening port number for the MMO server",
|
||||||
"Port": 9933,
|
"Port": 9933,
|
||||||
|
|
||||||
|
"// HttpApiPort": "Listening port number for the MMO server's API",
|
||||||
|
"HttpApiPort": 9934,
|
||||||
|
|
||||||
"// PingDelay": "delay (in milliseconds) for PNG response",
|
"// PingDelay": "delay (in milliseconds) for PNG response",
|
||||||
"PingDelay": 17,
|
"PingDelay": 17,
|
||||||
|
|
||||||
@ -27,7 +30,7 @@
|
|||||||
"LoungeInt" : [ ["3", 20.0, 30, 240, 0, 16] ],
|
"LoungeInt" : [ ["3", 20.0, 30, 240, 0, 16] ],
|
||||||
"Spaceport": [ ["1", 20.0, 300, 300, 60, 0], ["2", 120.0, 1800, 3600, 60, 0] ],
|
"Spaceport": [ ["1", 20.0, 300, 300, 60, 0], ["2", 120.0, 1800, 3600, 60, 0] ],
|
||||||
"Academy": [ ["1", 20.0, 300, 300, 60, 0] ],
|
"Academy": [ ["1", 20.0, 300, 300, 60, 0] ],
|
||||||
"ClubSSInt" : [ ["3", 20.0, 30, 240, 0, 16] ],
|
"ClubSSInt" : [ ["3", 20.0, 30, 240, 0, 16] ]
|
||||||
},
|
},
|
||||||
|
|
||||||
"// RacingMaxPlayers": "maximum players allowed in Thunder Run Racing (no more than 6)",
|
"// RacingMaxPlayers": "maximum players allowed in Thunder Run Racing (no more than 6)",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user