Code/SboxSuperuser/Components/SuperuserBootstrap.Chat.cs

A small partial component that implements IChatEvent to forward incoming chat messages to the session runtime chat observer or, if none and running on a dedicated server or editor testing is allowed, to the engine's UnavailableChat observer.

Networking
using Sandbox;

namespace SboxSuperuser.Components;

public sealed partial class SuperuserBootstrap : IChatEvent
{
	void IChatEvent.OnChatMessage( ChatMessageEvent message )
	{
		var chat = _session?.GetRuntime()?.Chat;
		if ( chat is not null ) chat.Observe( message );
		else if ( Application.IsDedicatedServer || Game.IsEditor && AllowEditorTesting )
			Engine.ChatIntegration.Platform.UnavailableChat.Observe( message );
	}
}