Flux.Server. Server-only, so constructing one on
a client errors.
Type definition
All listener callbacks receive the sending
Player as their first argument, before the
event’s own arguments.Fire()
Player
required
The recipient.
Args...
The payload. Encoded with the event’s schema if one is registered, otherwise with the
dynamic encoder.
Returns immediately. The payload is appended to that player’s reliable buffer and flushed
on the next
Heartbeat, up to about 16 ms later. See Batching.FireUnreliable()
FireAll()
FireAllClients
rather than a call per player.
Broadcasts use a separate buffer from per-player sends, and are flushed first. A
FireAll
issued after a Fire(player, ...) in the same frame will reach that player first, so do
not interleave the two when order matters.FireAllUnreliable()
Connect()
(player: Player, Args...) -> ()
required
Invoked once per received message. The sending player is always the first argument.
{ Disconnect: () -> () }
A plain table with a single
Disconnect method. Not an RBXScriptConnection, so it has
no Connected property and no Destroy.Each callback is dispatched with
task.spawn, so listeners run concurrently and an error
in one never blocks the others. Listeners are walked from the end of the list backwards,
which means the most recently connected runs first. Do not depend on order.Once()
Returns nothing. There is no handle, so a
Once listener cannot be cancelled before it
fires, and if the event never arrives it stays registered for the session. Use Connect
with a self-disconnect if you need to be able to back out.Wait()
(Player, Args...)
The sender, then the payload.
OnInvoke
This is a property with an interposed setter, not a method. Flux catches the assignment
through
__newindex and stores the handler in a module-level table keyed by event name.Three consequences follow: there is exactly one handler per name, assigning twice replaces
rather than adds, and every Server object built with that name shares it.pcall
The handler runs under
pcall. Errors are caught, transmitted as a message string, and
re-raised on the client by Invoke. Stack traces and error objects do not survive, so
return a structured result if the caller needs to branch on failure.task.spawn
Each request is handled in its own thread, so a yielding handler never blocks other
requests. Responses may therefore return out of order.
With no handler registered, incoming requests are silently dropped and the client yields
until its 60-second timeout. Register handlers during startup.
Shared state
The object itself carries almost nothing. Every operation looks up module-level state throughself._id.
string
The channel name. Private.
{ Types.Type }?
The schema passed at construction. Private.
Next steps
Client
The other half of the pair.
Events guide
Patterns and pitfalls in prose.
