added status

This commit is contained in:
2021-04-22 20:09:28 +02:00
parent 208110d1de
commit a110d00a0f
2 changed files with 18 additions and 2 deletions

View File

@@ -45,13 +45,16 @@ const nodeInit: NodeInitializer = (RED): void => {
await client.reconnect(-1, 1000) await client.reconnect(-1, 1000)
}else{ }else{
// TODO: Emit error // TODO: Emit error
this.emit("error")
} }
}else{
this.emit("disconnect")
} }
}) })
this.emit("connected")
return client return client
}catch(err){ }catch(err){
// TODO: handle error this.emit("error")
throw err throw err
} }
} }

View File

@@ -11,6 +11,19 @@ const nodeInit: NodeInitializer = (RED): void => {
const ts3Config = RED.nodes.getNode(config.configid) as Ts3ConfigNode const ts3Config = RED.nodes.getNode(config.configid) as Ts3ConfigNode
// HACK: ts3Config.on("connected") would not work because i dont know how to use typescript
ts3Config.addListener("connected",()=>{
this.status({fill:"green",shape:"dot",text:"Connected"})
})
ts3Config.addListener("disconnect",()=>{
this.status({fill:"grey",shape:"dot",text:"not conncted"})
})
ts3Config.addListener("error",()=>{
this.status({fill:"red",shape:"dot",text:"Error"})
})
this.on("input", async (msg,send,done) => { this.on("input", async (msg,send,done) => {
const client = await ts3Config.getConnection() const client = await ts3Config.getConnection()