Volt

create_comm_channel

Creates a communication channel for sending messages between actors.

Syntax

create_comm_channel(name: string?) -> (string, Channel)

Parameters

ParameterTypeDescription
namestring(Optional) Name for the channel

Returns

TypeDescription
stringThe channel identifier
ChannelThe channel object

Description

create_comm_channel creates a new communication channel that can be used to send and receive messages between actors and the main thread.

Channel Object

Property/MethodDescription
EventSignal to connect for receiving
Fire(...)Send a message through the channel

Example

local id, channel = create_comm_channel()

-- Listen for messages
channel.Event:Connect(function(message)
    print("Received:", message)
end)

-- Send to an actor
run_on_actor(someActor, [[
    local channelId = ...
    local channel = get_comm_channel(channelId)
    channel:Fire("Hello from actor!")
]], id)

Bidirectional Communication

-- Main thread
local id, channel = create_comm_channel()
channel.Event:Connect(function(response)
    print("Actor responded:", response)
end)

-- Actor sends back
run_on_actor(actor, [[
    local id = ...
    local channel = get_comm_channel(id)
    channel:Fire("Message received!")
]], id)

On this page