Version: 3.0.9

Net.Definitions Namespace

This namespace is for the Definitions feature.

Definitions.Create(definitions)#

function Create<T extends RemoteDeclarations>(
remotes: T,
globalMiddleware?: Net.GlobalMiddleware
): DefinitionBuilders<T>

Function

  • Parameters
    • remotes An object of remote definitions. See definitions for usage.
    • globalMiddleware (optional) A collection of global middleware to apply to all remotes in this definition
  • Returns a DefinitionsCreateResult

Example

shared/remotes.ts
import Net from "@rbxts/net";
const MyDefinitions = Net.Definitions.Create({
TestRemote: Net.Definitions.AsyncFunction<(name: string) => boolean>()
});

Definitions.ServerFunction<Server>(...)#

Definition function for creating a FunctionDefinition

Definitions.ServerToClientEvent<ServerArgs>(...)#

Definition function for creating an ServerEventDeclaration

Definitions.ClientToServerEvent<ClientArgs>(...)#

Definition function for creating an ClientEventDeclaration

Definitions.BidirectionalEvent<ServerArgs, ClientArgs>(...)#

Definition function for creating an BidirectionalEventDeclaration

Definitions.ServerAsyncFunction<Server>(...)#

Definition function for creating an ServerAsyncFunctionDefinition

Definitions.Namespace(definitions)#

Creates a group of definitions (returns DeclarationNamespace)

DefinitionsCreateResult<T>#

Contains the definition builders for a given definition (returned using Create in Net.Definitions)

interface DefinitionsCreateResult<T extends RemoteDeclarations> {
readonly Server: ServerDefinitionBuilder<T>;
readonly Client: ClientDefinitionBuilder<T>;
}

Server#

A ServerDefinitionBuilder object.

Client#

A ClientDefinitionBuilder object.

ServerDefinitionBuilder<T>#

Contains all the definition builders for server-side events and functions.

class ServerDefinitionBuilder<T extends RemoteDeclaration> {
Get(name: string): ServerEvent | ServerAsyncFunction | ServerFunction;
GetNamespace<K extends string>(name: K): SeverDefinitionBuilder<T[K]>;
OnEvent(name: string, callback: Callback): void;
OnFunction(name: string, callback: Callback): void;
}

Get(name)#

Will get the specified event by name, and return it. The returned object will be the type provided in the definition.

server/example.server.ts
import { Server as ServerRemotes } from "shared/remotes.ts";
const TestRemote = ServerRemotes.Get("TestRemote");

OnFunction(name, callback)#

Similar to Get but only works on events, and is pretty much a shortcut for Get(name).SetCallback(callback)

OnEvent(name, callback)#

Similar to Get but only works on events, and is pretty much a shortcut for Get(name).Connect(callback)

GetNamespace(name)#

Gets a child namespace under this namespace

ClientDefinitionBuilder<T>#

Contains all the definition builders for server-side events and functions.

class ClientDefinitionBuilder<T extends RemoteDeclaration> {
Get(name: string): ServerEvent | ServerAsyncFunction | ServerFunction;
GetNamespace<K extends string>(name: K): ClientDefinitionBuilder<T[K]>;
OnEvent(name: string, callback: Callback): void;
OnFunction(name: string, callback: Callback): void;
}

Get(name)#

Will get the specified event by name, and return it. The returned object will be the type provided in the definition.

Gets the specified remote definition and gets the client version of the event/function/asyncfunction

client/example.client.ts
import { Client as ClientRemotes } from "shared/remotes.ts";
const TestRemote = ClientRemotes.Get("TestRemote");

OnEvent(name, callback)#

Similar to Get but only works on events, and is pretty much a shortcut for Get(name).Connect(callback)

OnFunction(name, callback)#

Similar to Get but only works on events, and is pretty much a shortcut for Get(name).SetCallback(callback)

GetNamespace(name)#

Gets a child namespace under this namespace