apex.ipc.handle
Answers calls made with apex.ipc.invoke.
Syntax
apex.ipc.handle(topic: string, handler: (peer: Peer, ...any) -> ...any) -> Connection
Parameters
| Parameter | Type | Description |
|---|---|---|
topic | string | The topic that apex.ipc.invoke calls. It cannot start with @. |
handler | function | Called with the calling Peer and the call's values; what it returns goes back to the caller. |
Returns
| Type | Description |
|---|---|
Connection | Disconnect it to stop answering, or to set a different handler. |
Description
A topic has at most one handler in an instance; setting a second raises an error until the first is disconnected. The handler runs as its own task and may wait or yield. An error it raises is passed to the caller, which raises it in turn; so are return values that cannot be sent.
Example
apex.ipc.handle("inventory", function(peer, category)
local items = {}
for _, item in game.Players.LocalPlayer.Backpack:GetChildren() do
table.insert(items, item.Name)
end
return items
end)
These are Game executor contracts. Check build requirements and session lifetimes before using them.
