JavaScript 例程
Lua API
仅支持在NodeJs中使用
通过向 TCP 的 5180 端口发送 Lua API 来控制任务运行
const net = require('node:net');
async function run() {
let client = net.connect(5180, "127.0.0.1");
client.on("data", (data) => { console.log(data.toString()) });
client.write("scene(10087)");
}
run();
SDK
通过下载安装 SDK 来控制任务运行
NodeJs
let lebai_sdk = require("./lebai_sdk.js");
global.WebSocket = require("ws");
async function run() {
let lebai = await lebai_sdk.connect("127.0.0.1", false);
await lebai.start_sys();
await lebai.start_task("10087", null, null, false, 1);
}
run();
Web
<html>
<body>
<script type="module">
import init, * as lebai_sdk from './lebai_sdk.js';
async function run() {
await init();
let lebai = await lebai_sdk.connect("127.0.0.1", true);
await lebai.start_sys();
await lebai.start_task("10087", null, null, false, 1);
}
run();
</script>
</body>
</html>