Skip to main content

WeaverServer

This item only works when running on the server. Server

The server backend of Weaver.

All of the logic here is for starting and handling services alongside the communication bridge with the client.

Types

WeaverMethod

type WeaverMethod = (
InvokerPlayer,
...any
) → (...any)

WeaverExposed

interface WeaverExposed {}

The type that the Client table in WeaverService uses.

WeaverService

interface WeaverService {
Namestring--

The name of the service.

ClientWeaverExposed
[any]any
WeaverStart(selfWeaverService) → ()?
WeaverInit(selfWeaverService) → ()?
AttributeChangedRBXScriptSignal
GetAttributeChangedSignal(
Attributestring
) → RBXScriptSignal
GetAttribute(
Attributestring
) → any
SetAttribute(
Attributestring,
Valueany
) → ()
}

The type used for all services on the server.

WeaverMiddlewareCallback

type WeaverMiddlewareCallback = (
ClientPlayer,
...any
) → (
Continueboolean,
...any
)

WeaverMiddleware

Middleware used by the server.

Properties

Util

This item is read only and cannot be modified. Read Only
WeaverServer.Util: {Signal}

A module that contains all of the utility modules that Weaver exposes.

Functions

Start

This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. Yields
WeaverServer.Start(Middleware{}?) → ()

Starts Weaver.

If any middleware is provided, it will be used as as the default if no services provide their own.

caution

This will throw an error if Weaver has already started.

OnStart

This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. Yields
WeaverServer.OnStart() → ()

Yields until Weaver has started. Useful for external modules that are not ran as services.

If Weaver has already started, this will not yield.

GetService

WeaverServer.GetService(Namestring) → WeaverService

If the Name is used for a service, returns the WeaverService from the server.

caution

This will throw an error if Weaver has not started, or if Name is not used for a service.

GetServices

WeaverServer.GetServices() → {[string]WeaverService}

Returns all WeaverServices added.

caution

This will throw an error if Weaver has not started.

CreateService

WeaverServer.CreateService(Service{
Attributes{[string]any}?,
Client{[string]any}?,
Namestring,
[any]any,
WeaverStart(selfWeaverService) → ()?,
WeaverInit(selfWeaverService) → ()?
}) → WeaverMockService

Creates and adds a WeaverService before Weaver has started.

caution

This will throw an error if Weaver has started.

AddServices

WeaverServer.AddServices(HandleInstance) → {WeaverService}

Adds all services from Handle to Weaver automatically.

Returns an array of all of the added WeaverServices.

CreateRemoteSignal

WeaverServer.CreateRemoteSignal() → Marker

Creates a remote signal marker which is turned into a RemoteSignal when Weaver is started.

caution

This will only create a RemoteSignal if it is indexxed into the Client table.

CreateUnreliableSignal

WeaverServer.CreateUnreliableSignal() → Marker

Creates an unreliable signal marker which is turned into a RemoteSignal when Weaver is started. This is adjacent to Roblox's UnreliableRemoteEvent

caution

This will only create a RemoteSignal if it is indexxed into the Client table.

CreateEmptyProperty

WeaverServer.CreateEmptyProperty() → Marker

Creates a RemoteProperty with a value of nil when Weaver has started. If you would like to create a RemoteProperty with a value, set your property in your Client table to any value, i.e Service.Client.Property = 0

caution

This will only create a RemoteProperty if it is indexxed into the Client table.

Show raw api
{
    "functions": [
        {
            "name": "Start",
            "desc": "Starts Weaver.\n\nIf any middleware is provided, it will be used as as the default if no services provide their own.\n\n:::caution\n\nThis will throw an error if Weaver has already started.\n\n:::",
            "params": [
                {
                    "name": "Middleware",
                    "desc": "",
                    "lua_type": "{ Inbound: WeaverMiddleware?, Outbound: WeaverMiddleware? }?"
                }
            ],
            "returns": [],
            "function_type": "static",
            "yields": true,
            "source": {
                "line": 210,
                "path": "src/Server.luau"
            }
        },
        {
            "name": "OnStart",
            "desc": "Yields until Weaver has started. Useful for external modules that are not ran as services.\n\nIf Weaver has already started, this will not yield.",
            "params": [],
            "returns": [],
            "function_type": "static",
            "yields": true,
            "source": {
                "line": 385,
                "path": "src/Server.luau"
            }
        },
        {
            "name": "GetService",
            "desc": "If the `Name` is used for a service, returns the [WeaverService](WeaverServer#WeaverService) from the server.\n\n:::caution\n\nThis will throw an error if Weaver has not started, or if `Name` is not used for a service.\n\n:::",
            "params": [
                {
                    "name": "Name",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "WeaverService"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 407,
                "path": "src/Server.luau"
            }
        },
        {
            "name": "GetServices",
            "desc": "Returns all [WeaverService]s added.\n\n:::caution\n\nThis will throw an error if Weaver has not started.\n\n:::",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ [string]: WeaverService }"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 426,
                "path": "src/Server.luau"
            }
        },
        {
            "name": "CreateService",
            "desc": "Creates and adds a [WeaverService](WeaverServer#WeaverService) before Weaver has started.\n\n:::caution\n\nThis will throw an error if Weaver has started.\n\n:::",
            "params": [
                {
                    "name": "Service",
                    "desc": "",
                    "lua_type": "{ Attributes: { [string]: any }?, Client: { [string]: any }?, Name: string, [any]: any, WeaverStart: (self: WeaverService) -> ()?, WeaverInit: (self: WeaverService) -> ()? }"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "WeaverMockService"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 442,
                "path": "src/Server.luau"
            }
        },
        {
            "name": "AddServices",
            "desc": "Adds all services from `Handle` to Weaver automatically.\n\nReturns an array of all of the added [WeaverServices](WeaverServer#WeaverService).",
            "params": [
                {
                    "name": "Handle",
                    "desc": "",
                    "lua_type": "Instance"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ WeaverService }"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 470,
                "path": "src/Server.luau"
            }
        },
        {
            "name": "CreateRemoteSignal",
            "desc": "Creates a remote signal marker which is turned into a [RemoteSignal] when Weaver is started.\n\n:::caution\n\nThis will only create a [RemoteSignal] if it is indexxed into the Client table.\n\n:::",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Marker"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 500,
                "path": "src/Server.luau"
            }
        },
        {
            "name": "CreateUnreliableSignal",
            "desc": "Creates an unreliable signal marker which is turned into a [RemoteSignal] when Weaver is started. This is adjacent to Roblox's [UnreliableRemoteEvent]\n\n:::caution\n\nThis will only create a [RemoteSignal] if it is indexxed into the Client table.\n\n:::",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Marker"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 514,
                "path": "src/Server.luau"
            }
        },
        {
            "name": "CreateEmptyProperty",
            "desc": "Creates a [RemoteProperty] with a value of `nil` when Weaver has started. If you would like to create a [RemoteProperty] with a value, set your property in your `Client` table to any value, i.e `Service.Client.Property = 0`\n\n:::caution\n\nThis will only create a [RemoteProperty] if it is indexxed into the Client table.\n\n:::",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Marker"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 528,
                "path": "src/Server.luau"
            }
        }
    ],
    "properties": [
        {
            "name": "Util",
            "desc": "A module that contains all of the utility modules that Weaver exposes.",
            "lua_type": "{ Signal }",
            "readonly": true,
            "source": {
                "line": 540,
                "path": "src/Server.luau"
            }
        }
    ],
    "types": [
        {
            "name": "WeaverMethod",
            "desc": "",
            "lua_type": "(self: WeaverExposed, Invoker: Player, ...any) -> (...any)",
            "source": {
                "line": 31,
                "path": "src/Server.luau"
            }
        },
        {
            "name": "WeaverExposed",
            "desc": "The type that the `Client` table in [WeaverService](WeaverServer#WeaverService) uses.",
            "fields": [
                {
                    "name": "Server",
                    "lua_type": "WeaverService",
                    "desc": ""
                },
                {
                    "name": "[string]",
                    "lua_type": "RemoteSignal | RemoteProperty | WeaverMethod",
                    "desc": ""
                }
            ],
            "source": {
                "line": 72,
                "path": "src/Server.luau"
            }
        },
        {
            "name": "WeaverService",
            "desc": "The type used for all services on the server.",
            "fields": [
                {
                    "name": "Name",
                    "lua_type": "string",
                    "desc": "The name of the service."
                },
                {
                    "name": "Client",
                    "lua_type": "WeaverExposed",
                    "desc": ""
                },
                {
                    "name": "[any]",
                    "lua_type": "any",
                    "desc": ""
                },
                {
                    "name": "WeaverStart",
                    "lua_type": "(self: WeaverService) -> ()?",
                    "desc": ""
                },
                {
                    "name": "WeaverInit",
                    "lua_type": "(self: WeaverService) -> ()?",
                    "desc": ""
                },
                {
                    "name": "AttributeChanged",
                    "lua_type": "RBXScriptSignal",
                    "desc": ""
                },
                {
                    "name": "GetAttributeChangedSignal",
                    "lua_type": "(self: WeaverService, Attribute: string) -> RBXScriptSignal",
                    "desc": ""
                },
                {
                    "name": "GetAttribute",
                    "lua_type": "(self: WeaverService, Attribute: string) -> any",
                    "desc": ""
                },
                {
                    "name": "SetAttribute",
                    "lua_type": "(self: WeaverService, Attribute: string, Value: any) -> ()",
                    "desc": ""
                }
            ],
            "source": {
                "line": 98,
                "path": "src/Server.luau"
            }
        },
        {
            "name": "WeaverMiddlewareCallback",
            "desc": "",
            "lua_type": "(Client: Player, ...any) -> (Continue: boolean, ...any)",
            "source": {
                "line": 122,
                "path": "src/Server.luau"
            }
        },
        {
            "name": "WeaverMiddleware",
            "desc": "[Middleware](/docs/communication/middleware) used by the server.",
            "lua_type": "WeaverMiddlewareCallback | { WeaverMiddlewareCallback }",
            "source": {
                "line": 128,
                "path": "src/Server.luau"
            }
        }
    ],
    "name": "WeaverServer",
    "desc": "The server backend of Weaver.\n\nAll of the logic here is for starting and handling services alongside the communication bridge with the client.",
    "realm": [
        "Server"
    ],
    "source": {
        "line": 10,
        "path": "src/Server.luau"
    }
}