30 lines
671 B
TypeScript
30 lines
671 B
TypeScript
import { NodeInitializer } from "node-red";
|
|
import { Ts3ConfigNode } from "../ts3-config/types";
|
|
import { Ts3GetConfig, Ts3GetNode } from "./types";
|
|
|
|
const nodeInit: NodeInitializer = (RED): void => {
|
|
function Ts3Get(
|
|
this: Ts3GetNode,
|
|
config: Ts3GetConfig
|
|
): void {
|
|
RED.nodes.createNode(this, config);
|
|
|
|
const ts3Config = RED.nodes.getNode(config.configid) as Ts3ConfigNode
|
|
|
|
this.on("input", async (msg,send,done) => {
|
|
const client = await ts3Config.getConnection()
|
|
|
|
let clients = await client.clientList({ clientType: 0 })
|
|
|
|
msg.payload = clients
|
|
|
|
send(msg)
|
|
done()
|
|
})
|
|
}
|
|
|
|
RED.nodes.registerType("ts3-get", Ts3Get);
|
|
};
|
|
|
|
export = nodeInit;
|