Class ServerHost
- Namespace
- BSGameLib.Server
- Assembly
- BSGameLib.Server.dll
Runs a game's server. It builds the host, registers the server's services and runs it until it stops.
public class ServerHost : IDisposable
- Inheritance
-
ServerHost
- Implements
- Inherited Members
Constructors
ServerHost()
Creates a host with the default settings.
public ServerHost()
ServerHost(IServerSettings)
Creates a host with settings.
public ServerHost(IServerSettings settings)
Parameters
settingsIServerSettings
Exceptions
- ArgumentNullException
settingsis null.
Fields
ReloadConfigOnChangeKey
The host configuration key that turns watching configuration files for changes on or off.
public const string ReloadConfigOnChangeKey = "hostBuilder:reloadConfigOnChange"
Field Value
Methods
Configure(IServiceCollection)
Register your own services into the DI container, after the engine's own registrations
and before the host starts. The server-side counterpart to Game.Configure.
protected virtual void Configure(IServiceCollection services)
Parameters
servicesIServiceCollection
ConfigureHost(IHostBuilder)
Customize the host builder itself -- the seam for anything that hangs off
IHostBuilder rather than the service collection, logging being the usual
case (UseSerilog, UseNLog, and so on).
protected virtual void ConfigureHost(IHostBuilder builder)
Parameters
builderIHostBuilder
Remarks
BSGameLib deliberately configures no logging provider of its own. It used to call
UseSerilog here with a fixed console+rolling-file setup and a hardcoded list of
category overrides, which chose a logging framework on every consumer's behalf and
dragged four Serilog packages into anyone referencing this assembly. The engine logs
through ILogger/ILogger<T> everywhere else and has no opinion about
where those records end up. Configure nothing and you still get
Host.CreateDefaultBuilder's console provider.
Dispose()
Marks the host as disposed.
public void Dispose()
Dispose(bool)
Marks the host as disposed, once.
protected virtual void Dispose(bool disposing)
Parameters
disposingbool
Run()
Builds the host and runs the server. It returns when the server stops.
public void Run()