dev/samples/arena/Code/SuperuserArena/Components/SampleSession.cs

A Component that starts an isolated engine networking lobby session when the component starts. It checks that networking is not already active and that the process is either a dedicated server or running in the editor, then creates a private, hidden lobby with a max of 4 players.

Networking
using Sandbox;
using Sandbox.Network;

namespace SuperuserArena.Components;

/// <summary>Starts an isolated engine network session for this development sample.</summary>
public sealed class SampleSession : Component
{
	protected override void OnStart()
	{
		if ( Networking.IsActive || !Application.IsDedicatedServer && !Game.IsEditor ) return;
		Networking.CreateLobby( new LobbyConfig
		{
			Name = "Superuser arena sample",
			Privacy = LobbyPrivacy.Private,
			Hidden = true,
			MaxPlayers = 4
		} );
	}
}