A network admission handler on the SuperuserBootstrap component that implements Component.INetworkListener.AcceptConnection. It allows connections unless the process is the dedicated server or host editor testing is disabled, in which case it delegates the decision to a runtime object; if no runtime is available it rejects the connection with a moderation-not-ready reason.
using Sandbox;
namespace SboxSuperuser.Components;
public sealed partial class SuperuserBootstrap : Component.INetworkListener
{
bool Component.INetworkListener.AcceptConnection( Connection connection, ref string reason )
{
if ( !Networking.IsHost || !Application.IsDedicatedServer && !(Game.IsEditor && AllowEditorTesting) ) return true;
var runtime = _session?.GetRuntime();
if ( runtime is not null ) return runtime.AcceptConnection( connection, ref reason );
reason = "Server moderation is not ready; try again later.";
return false;
}
}