Chat
Built-in chat with real-time server-side moderation.
Overview
Clients send chat with
client.chat(text); the server broadcasts it to every instance the sender is a member of. No handlers or event names to wire up.Moderation
The server moderates every message in real time with the
onChatMessage hook. Return true to pass a message through, a string to rewrite it, or false (or throw) to block it - only the sender is notified of a block.✦
Pair chat with the built-in
rateLimit middleware to stop spam: mesh.use(rateLimit({ chat: 2 })).Kicking sessions
session.kick(reason?) is a general session control, not a chat feature - it works anywhere you have a session (event handlers, middleware, admin tooling). The client is told why via client.onKick(reason => ...), then force-disconnected. Chat moderation is simply its most common trigger.