Forest Logo
search
package_2

link

By @reimakesgames

Roblox

Mirrored

Link

A simplistic, close to Roblox, RemoteEvent/RemoteFunction wrapper.

Why Link?

Link is an easily extensible networking wrapper. It can support middleware to enable features like serialization and deserialization, without the need to complicate your inputted data.

Features

  • Basic RemoteEvent/RemoteFunction features
  • Pseudo-remotes to allow easier VSCode integration

API

Link

Link:CreateEvent(name: string): EventLink

Creates a new Event.

local ExampleEvent = Link:CreateEvent("Event")

Link:FindEvent(name: string): EventLink | nil

Finds the event within the Connections table. Returns nil if not found.
Works similarly to Instance:FindFirstChild.

local ExampleEvent = Link:FindEvent("EventName")

Link:WaitEvent(name: string, timeout: number?): EventLink

Waits for the event in the Connections table.

This method yields the current thread until the event is found.

local ExampleEvent = Link:WaitEvent("EventName")
local ExampleEvent = Link:WaitEvent("EventName", 5)

Link:CreateFunction(name: string): FunctionLink

Creates a new Function.

local ExampleFunction = Link:CreateFunction("Function")

Link:FindFunction(name: string): FunctionLink | nil

Finds the function within the Connections table. Returns nil if not found.
Works similarly to Instance:FindFirstChild.

local ExampleFunction = Link:FindFunction("FunctionName")

Link:WaitFunction(name: string, timeout: number?): FunctionLink

Waits for the function in the Connections table.

This method yields the current thread until the function is found.

local ExampleFunction = Link:WaitFunction("FunctionName")
local ExampleFunction = Link:WaitFunction("FunctionName", 5)

Link:Connections: { [string]: EventLink | FunctionLink }

The dictionary where the connections are stored

example:

KeyValue
Prefix_Name_SuffixEventLink
REMOTE_NameFunctionLink

Event

EventLink:FireClient(player: Player, ...any): nil

Server -> Client

Fires the event to the specified player.

local ExampleEvent = Link:CreateEvent("Event")
ExampleEvent:FireClient(player, "Hello", "World")

EventLink:FireAllClients(...any): nil

Server -> All Clients

Fires every player within the game

local ExampleEvent = Link:CreateEvent("Event")
ExampleEvent:FireAllClients("Hello", "World")

EventLink:FireClients(selectedPlayers: Array<Players>, ...any): nil

Server -> Selected Clients

Fires the selected players within the array

local ExampleEvent = Link:CreateEvent("Event")
ExampleEvent:FireClients({player1, player2}, "Hello", "World")

EventLink:FireClientsExcept(excludedPlayers: Array<Players>, ...any): nil

Server -> All Clients Except Selected

Fires every player within the game, except the selected players within the array

local ExampleEvent = Link:CreateEvent("Event")
ExampleEvent:FireClientsExcept({player1, player2}, "Hello", "World")

EventLink:FireServer(...any): nil

Client -> Server

Fires to the server with the provided parameters

local ExampleEvent = Link:WaitEvent("Event")
ExampleEvent:FireServer("Hello", "World")

EventLink.Event: FastSignal.Class

Event you can connect to.

local Event = Link:CreateEvent("Event")
ExampleEvent.Event:Connect(function(...)
	print(...)
end)

Function

FunctionLink:InvokeClient(player: Player, ...any): any

Server -> Client
Yields

Considered by Roblox as unsafe. Use with caution.
Invokes the specified player with the provided parameters.

local ExampleFunction = Link:CreateFunction("Function")
local result = ExampleFunction:InvokeClient(player, "Hello", "World")

FunctionLink:InvokeServer(...any): any

Client -> Server
Yields

Invokes the server with the provided parameters.

local ExampleFunction = Link:WaitFunction("Function")
local result = ExampleFunction:InvokeServer("Hello", "World")

FunctionLink:OnClientInvoke(callback: (...any) -> any): nil)

Similar to RemoteFunction.OnClientInvoke

A setter for the OnClientInvoke callback which is called when the server invokes the client.

local ExampleFunction = Link:CreateFunction("Function")
ExampleFunction:OnClientInvoke(function(...)
	print(...)
	return true
end)

FunctionLink:OnServerInvoke(callback: (player: Player, ...any) -> any): nil)

Similar to RemoteFunction.OnServerInvoke

A setter for the OnServerInvoke callback which is called when the client invokes the server.

local ExampleFunction = Link:CreateFunction("Function")
ExampleFunction:OnServerInvoke(function(player, ...)
	print("Player", player.Name, "invoked the server with", ...)
	return true
end)

Package Details

Install command (Click to copy)


Version

0.3.0

License

BSD-3-Clause

check_circle

Safe for commercial use

infoThe copyright notice must be preserved in copies. The author's name may not be used to promote your product.

infoLicense identified from the packaged LICENSE file; the manifest declared none.

Automated license review — not legal advice.