Skip to content

defineNamespace

Groups packet and query definitions and coordinates their IDs between the server and clients.

ByteNetMax.defineNamespace(Name, DefinitionCallback)

Parameters

Parameter Type Description
Name string Stable, unique namespace name
DefinitionCallback () -> table Returns optional packets and queries tables

Returns

{
    packets = { [string]: Packet },
    queries = { [string]: Query },
}

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.