Class ChatSystem
- Namespace
- FishMMO.Server.Implementation.World.SceneServer
- Assembly
- FishMMO.Server.dll
Manages all chat functionality including public, party, guild, whisper, and system messages with rate limiting and spam protection. Game logic and Broadcasts run synchronously on the main thread. Database operations are fire-and-forget async to avoid blocking the main thread. Results from async DB queries that require main-thread Broadcasts are marshalled via IChatSystemMainThreadQueueData.
[CreateAssetMenu(fileName = "ChatSystem", menuName = "FishMMO/Server/SceneServer/Chat System", order = 1)]
[RequiresDataContainer(typeof(ChatSystemRuntimeData))]
[RequiresDataContainer(typeof(ChatSystemMainThreadQueueData))]
[RequiresDataContainer(typeof(AsyncWorkerData))]
public class ChatSystem : ServerBehaviour, IServerBehaviour<INetworkManagerWrapper, ServerManager, NetworkConnection, IServerBehaviour>, IServerComponent<INetworkManagerWrapper, ServerManager, NetworkConnection, IServerBehaviour>, IChatSystem, IServerBehaviour, IServerComponent, IChatHelper
- Inheritance
-
ObjectScriptableObjectChatSystem
- Implements
- Inherited Members
-
ScriptableObject.SetDirty()ScriptableObject.CreateInstance<T>()Object.GetEntityId()Object.MemberwiseClone()Object.GetInstanceID()Object.GetHashCode()Object.InstantiateAsync<T>(T)Object.InstantiateAsync<T>(T, Transform)Object.InstantiateAsync<T>(T, Vector3, Quaternion)Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)Object.Instantiate(Object, Vector3, Quaternion)Object.Instantiate(Object, Vector3, Quaternion, Transform)Object.Instantiate(Object)Object.Instantiate(Object, Scene)Object.Instantiate<T>(T, InstantiateParameters)Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)Object.Instantiate(Object, Transform)Object.Instantiate<T>(T)Object.Instantiate<T>(T, Vector3, Quaternion)Object.Instantiate<T>(T, Vector3, Quaternion, Transform)Object.Instantiate<T>(T, Transform)Object.Destroy(Object)Object.DestroyImmediate(Object)Object.DontDestroyOnLoad(Object)Object.DestroyObject(Object)Object.FindObjectsOfType<T>()Object.FindObjectsByType<T>(FindObjectsSortMode)Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)Object.FindObjectOfType<T>()Object.FindFirstObjectByType<T>()Object.FindAnyObjectByType<T>()Object.FindFirstObjectByType<T>(FindObjectsInactive)Object.FindAnyObjectByType<T>(FindObjectsInactive)Object.FindObjectsByType<T>()Object.FindObjectsByType<T>(FindObjectsInactive)Object.ToString()Object.nameObject.hideFlags
Remarks
Registered at Player, and therefore not audited. The audit hook at the access gate records commands registered above Player; reading a list of what you can already run is not an operator action.
Decided on the server, from the caller's own level. The listing is built by ChatCommandHelpListing against the character's server-loaded AccessLevel — never from anything the client sends — so a player is never shown a game master or administrator command, and a game master never an administrator one.
Registered here, with the chat system, rather than beside the operator sets: those are pinned to exactly one registration each.
Properties
AllowRepeatMessages
If true, allows repeat messages from clients without spam filtering.
public bool AllowRepeatMessages { get; }
Property Value
MaxMessageLength
Maximum allowed chat message length.
public int MaxMessageLength { get; }
Property Value
MessagePumpRate
The server chat message pump rate limit in seconds.
public float MessagePumpRate { get; }
Property Value
MessageRateLimit
The server chat rate limit in milliseconds. Should match the client's UIChat.messageRateLimit.
public float MessageRateLimit { get; }
Property Value
Methods
GetChannelCommand(ChatChannel)
Gets the chat command handler for a specific chat channel.
public ChatCommand GetChannelCommand(ChatChannel channel)
Parameters
channelChatChannelChat channel to get the command for.
Returns
- ChatCommand
Chat command delegate for the channel.
InitializeOnce()
Initializes the chat system, registering broadcast handlers and chat helper commands.
public override ServerComponentInitializationStatus InitializeOnce()
Returns
OnDeinitialize()
Cleans up the chat system, unregistering broadcast handlers and chat helper commands.
public override void OnDeinitialize()
OnGuildChat(IPlayerCharacter, ChatBroadcast)
Handles guild chat: persists a live line for the other scene servers and delivers it to this server's members of the guild. Returns false so the caller does not persist it again.
public bool OnGuildChat(IPlayerCharacter sender, ChatBroadcast msg)
Parameters
senderIPlayerCharacterPlayer character sending the message, or null for a pumped line.
msgChatBroadcastChat broadcast message; its text starts with the guild ID.
Returns
- bool
False — persistence is handled here.
OnPartyChat(IPlayerCharacter, ChatBroadcast)
Handles party chat: persists a live line for the other scene servers and delivers it to this server's members of the party. Returns false so the caller does not persist it again.
public bool OnPartyChat(IPlayerCharacter sender, ChatBroadcast msg)
Parameters
senderIPlayerCharacterPlayer character sending the message, or null for a pumped line.
msgChatBroadcastChat broadcast message; its text starts with the party ID.
Returns
- bool
False — persistence is handled here.
OnRegionChat(IPlayerCharacter, ChatBroadcast)
Handles region chat messages, broadcasting to all connections in the sender's scene.
public bool OnRegionChat(IPlayerCharacter sender, ChatBroadcast msg)
Parameters
senderIPlayerCharacterPlayer character sending the message.
msgChatBroadcastChat broadcast message.
Returns
- bool
True for a live line, so the caller writes it to the chat log.
OnSayChat(IPlayerCharacter, ChatBroadcast)
Handles say (local) chat messages, broadcasting to all observers of the sender.
public bool OnSayChat(IPlayerCharacter sender, ChatBroadcast msg)
Parameters
senderIPlayerCharacterPlayer character sending the message.
msgChatBroadcastChat broadcast message.
Returns
- bool
True for a live line, so the caller writes it to the chat log.
Remarks
Scoped by the sender's observer set, which is already range-limited: the player distance condition admits a viewer at up to 100 m, so an observer of the speaker is by construction someone standing near enough to hear them. Re-deriving earshot from positions here would be a second copy of a radius the interest system already applies, and the two would drift the moment either was retuned.
OnSendDiscordMessage(long, long, string)
Allows the server to send Discord messages to a specific world server.
public void OnSendDiscordMessage(long worldServerID, long sceneServerID, string message)
Parameters
worldServerIDlongWorld server ID to send the message to.
sceneServerIDlongScene server ID (for context).
messagestringDiscord message text.
OnSendSystemMessage(NetworkConnection, string)
Allows the server to send system messages to the connection.
public void OnSendSystemMessage(NetworkConnection conn, string message)
Parameters
connNetworkConnectionNetwork connection to send the system message to.
messagestringSystem message text.
OnTeamChat(IPlayerCharacter, ChatBroadcast)
Delivers a team message to the sender's teammates in the arena they are standing in.
public bool OnTeamChat(IPlayerCharacter sender, ChatBroadcast msg)
Parameters
senderIPlayerCharactermsgChatBroadcast
Returns
Remarks
Local and synchronous. Every seat of a match is connected to the scene server hosting its instance, so there is no other server to reach and no database to go through; the team registry the coordinator publishes says who is on which side. A sender who is not seated in a live-or-pending arena match is told so rather than silently dropped.
Written to the chat log like any other player chat, but never relayed between scene servers: everyone on a team is in the one arena scene on this server.
OnTellChat(IPlayerCharacter, ChatBroadcast)
Handles tell (private) chat messages. A target on this server is delivered to at once; a live whisper to anybody else is looked up in the database, to tell the sender whether it was relayed or the target is offline, and persisted so the target's own server delivers it. Returns false to suppress the caller's DB save — persistence is handled here.
public bool OnTellChat(IPlayerCharacter sender, ChatBroadcast msg)
Parameters
senderIPlayerCharacterPlayer character sending the message.
msgChatBroadcastChat broadcast message.
Returns
- bool
False — persistence is handled inside the async path.
OnTradeChat(IPlayerCharacter, ChatBroadcast)
Handles trade chat messages. Live messages are buffered per-world for batched delivery. Pump-sourced messages (sender == null) are broadcast immediately.
public bool OnTradeChat(IPlayerCharacter sender, ChatBroadcast msg)
Parameters
senderIPlayerCharacterPlayer character sending the message, or null for pump-sourced.
msgChatBroadcastChat broadcast message.
Returns
- bool
True if message was accepted (live sender), false otherwise.
OnUpdate(float)
Each frame: drain the lock-free incoming chat queue, then the main-thread action queue.
protected override void OnUpdate(float deltaTime)
Parameters
deltaTimefloat
OnWorldChat(IPlayerCharacter, ChatBroadcast)
Handles world chat messages. Live messages are buffered per-world for batched delivery. Pump-sourced messages (sender == null) are broadcast immediately.
public bool OnWorldChat(IPlayerCharacter sender, ChatBroadcast msg)
Parameters
senderIPlayerCharacterPlayer character sending the message, or null for pump-sourced.
msgChatBroadcastChat broadcast message.
Returns
- bool
True if message was accepted (live sender), false otherwise.