Version: 2.1.5

Using your definitions

Say that we have our example definition file here:

shared/remotes.ts
import { Definitions } from "@rbxts/net";
const Remotes = Definitions.Create({
GetPlayerInventory: Definitions.ServerAsyncFunction<() => SerializedPlayerInventory>(),
GetPlayerEquipped: Definitions.ServerAsyncFunction<() => SerializedPlayerEquipped>(),
PlayerInventoryUpdated: Definitions.ServerToClientEvent<[event: InventoryUpdatedEvent]>(),
PlayerEquippedUpdated: Definitions.ServerToClientEvent<[event: EquippedUpdatedEvent]>(),
PlayerUnequipItem: Definitions.ClientToServerEvent<[itemId: number]>(),
PlayerEquipItem: Definitions.ClientToServerEvent<[itemId: number]>(),
});
export = Remotes;

How would we approach using this to actually be able to send messages between the server and client?

Usage from the server#

server/main.server.ts
import Remotes from "shared/remotes";