defineNamespace¶
Groups packet and query definitions and coordinates their IDs between the server and clients.
Parameters¶
| Parameter | Type | Description |
|---|---|---|
Name |
string |
Stable, unique namespace name |
DefinitionCallback |
() -> table |
Returns optional packets and queries tables |
Returns¶
Example¶
local Network = ByteNetMax.defineNamespace("Chat", function()
return {
packets = {
SendMessage = ByteNetMax.definePacket({
value = ByteNetMax.string,
}),
},
queries = {},
}
end)
The empty tables are optional. A packet-only namespace may omit queries, and a query-only namespace may omit packets.
Both sides are mandatory
Define a namespace in one shared ModuleScript, initialize it on the server first, and require the exact same module on the client. Do not maintain two hand-written copies of the schema. See Required initialization.