Module ipc
IPC interface for communication between UI and Web processes
In Luakit there is a single UI Lua state, but there may be multiple web processes, each of which have a separate Lua state. This interface can be used to communicate between the UI and web processes.
An interface similar to Luakit's signals handling is provided, and supports serializing multiple Lua parameters.
-- In UI process local wm = require_web_module("test_wm") wm:add_signal("test", function (_, text) msg.info("Web process said %s!", text) end) -- In test_wm web module local ui = ipc_channel("test_wm") ui:emit_signal("test", "hello")
Functions
ipc.ipc_channel (name)
Open an IPC channel.
Open an IPC channel and create an ipc_channel
object. Signals
emitted on this object on the web process will call signal handlers
on the UI process, and vice versa.
Parameters
-
nameType: stringA name that identifies the channel.
Return Values
-
ipc_channelAn IPC channel endpoint object.
ipc.require_web_module (name)
Require a Lua module on the web process.
Load the named module on all web process Lua states. The module will be loaded on any future web process Lua states.
For convenience, this function returns an IPC channel with the same name as the web module.
Parameters
-
nameType: stringThe name of the module to load.
Return Values
-
ipc_channelAn IPC channel endpoint object.
Attribution
Copyright
- 2016 Aidan Holm