Start typing to search packages!
relay
By @karlobii
Roblox
Mirrored from WallyRelay
Relay is a lightweight Roblox networking utility for routing client requests to server methods and sending server events or state updates to clients. It provides reliable events, unreliable events, request/response calls, and instance-scoped remotes.
Installation
Install karlobii/relay with Wally. Relay depends on
sleitnick/signal for changed-state signals.
Quick start
Require Relay from its package root on both the server and client:
local Relay = require(path.to.Relay)
On the server, register only the methods clients are allowed to call:
local service = {}
function service:requestGreeting(player: Player, name: string): string
return "Hello, " .. name
end
local server = Relay.server.new("GreetingService", service, {
service.requestGreeting,
})
server:fireAll("showGreeting", "Welcome!")
On the client, provide handlers for server messages and call the registered server method:
local handlers = {}
function handlers:showGreeting(message: string)
print(message)
end
local client = Relay.client.new("GreetingService", handlers)
local greeting = client:fetch("requestGreeting", "Ada")
Client-accessible methods receive the calling Player as their first argument.
Methods invoked on the client receive the handler table as self.
API overview
Relay.server.new(tag, module?, clientAccess?)creates a server endpoint.tagcan be a shared string or anInstance; instance tags are assigned and replicated by Relay.Relay.client.new(tag, module)creates the corresponding client endpoint.server:fire(playerOrPlayers, method, ...)andserver:fireAll(method, ...)send reliable events.fireUnreliableandfireAllUnreliableuse anUnreliableRemoteEvent.client:fire(method, ...)sends a reliable request without a return value.client:fetch(method, ...)uses aRemoteFunctionand yields for its result.server:set(...),setAll(...),setAllExcept(...), andsetRecipients(...)update client-side values.client:getServerChangedSignal(key)returns a signal that fires when that value changes.server:addRecipient(player),removeRecipient(player), andclearRecipients()manage the recipient list used byfireRecipients,fireRecipientsUnreliable, andsetRecipients.- Call
destroy()on either endpoint when it is no longer needed. Relay disconnects its listeners and releases owned resources; destroying a client endpoint does not destroy the server-owned remotes. Server endpoints automatically remove departing players from their recipient lists. Methods other thandestroy()raise an error if called after their endpoint has been destroyed; callingdestroy()more than once is safe.
Always validate client-provided arguments and authorize requests in your server methods. Registering a method grants every connected client permission to call it.
Package Details
Install command (Click to copy)
Version
0.1.0-test
License
MIT
Safe for commercial use
The package archive does not include its license text; the license is declared in its manifest metadata.
Automated license review — not legal advice.
