Partial class for a Connection probe component called CompatibilityProbe. Implements Component.INetworkListener to log connection acceptance, connection and active events, and can reject one configured test Steam ID at admission. The rest of the partial class (CanRun, FindActiveProbe) lives elsewhere.
using Sandbox;
namespace SboxSuperuser.Components;
public sealed partial class CompatibilityProbe : Component.INetworkListener
{
/// <summary>Optional test account to reject at admission; empty allows every connection.</summary>
[Property, Group( "Testing" )]
public string RejectedTestSteamId { get; set; } = "";
bool Component.INetworkListener.AcceptConnection( Connection connection, ref string reason )
{
if ( !CanRun || FindActiveProbe() != this )
{
return true;
}
var reject = connection.SteamId.ToString() == RejectedTestSteamId;
Log.Info( $"[Superuser T01] AcceptConnection steamId={connection.SteamId}; rejected={reject}" );
if ( reject )
{
reason = "Superuser T01 admission probe: this test account is deliberately rejected.";
}
return !reject;
}
void Component.INetworkListener.OnConnected( Connection connection )
{
if ( CanRun && FindActiveProbe() == this )
{
Log.Info( $"[Superuser T01] OnConnected steamId={connection.SteamId}" );
}
}
void Component.INetworkListener.OnActive( Connection connection )
{
if ( CanRun && FindActiveProbe() == this )
{
Log.Info( $"[Superuser T01] OnActive steamId={connection.SteamId}" );
}
}
}