SD changes
This commit is contained in:
parent
7cb1ad84a4
commit
3eae70a39e
1 changed files with 13 additions and 9 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
* StreamDeck object containing all required code to establish
|
* StreamDeck object containing all required code to establish
|
||||||
* communication with SD-Software and the Property Inspector
|
* communication with SD-Software and the Property Inspector
|
||||||
*/
|
*/
|
||||||
class ELGSDStreamDeck {
|
class ELGSDStreamDeck {
|
||||||
port;
|
port;
|
||||||
uuid;
|
uuid;
|
||||||
messageType;
|
messageType;
|
||||||
|
|
@ -70,7 +70,7 @@ class ELGSDStreamDeck {
|
||||||
this.websocket.onerror = (evt) => {
|
this.websocket.onerror = (evt) => {
|
||||||
const error = `WEBOCKET ERROR: ${evt}, ${evt.data}, ${SocketErrors[evt?.code]}`;
|
const error = `WEBOCKET ERROR: ${evt}, ${evt.data}, ${SocketErrors[evt?.code]}`;
|
||||||
console.warn(error);
|
console.warn(error);
|
||||||
this.log(error);
|
this.logMessage(error);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.websocket.onclose = (evt) => {
|
this.websocket.onclose = (evt) => {
|
||||||
|
|
@ -78,10 +78,9 @@ class ELGSDStreamDeck {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.websocket.onmessage = (evt) => {
|
this.websocket.onmessage = (evt) => {
|
||||||
const data = evt?.data ? JSON.parse(evt.data) : {};
|
const data = evt?.data ? JSON.parse(evt.data) : null;
|
||||||
const { action, event } = data;
|
const { action, event } = data;
|
||||||
const message = action ? `${action}.${event}` : event;
|
const message = action ? `${action}.${event}` : event;
|
||||||
|
|
||||||
if (message && message !== '') this.emit(message, data);
|
if (message && message !== '') this.emit(message, data);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -100,9 +99,11 @@ class ELGSDStreamDeck {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
this.websocket.send(JSON.stringify(json));
|
this.websocket.send(JSON.stringify(json));
|
||||||
|
} else {
|
||||||
|
console.error('Websocket not defined');
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Websocket not defined');
|
console.error('Websocket not defined');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -177,7 +178,7 @@ class ELGSDStreamDeck {
|
||||||
setSettings(payload, context) {
|
setSettings(payload, context) {
|
||||||
this.send(Events.setSettings, this.uuid, {
|
this.send(Events.setSettings, this.uuid, {
|
||||||
action: this?.actionInfo?.action,
|
action: this?.actionInfo?.action,
|
||||||
payload: payload || {},
|
payload: payload || null,
|
||||||
targetContext: context,
|
targetContext: context,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -219,7 +220,7 @@ class ELGSDStreamDeck {
|
||||||
sendToPlugin(payload, context) {
|
sendToPlugin(payload, context) {
|
||||||
this.send(Events.sendToPlugin, this.uuid, {
|
this.send(Events.sendToPlugin, this.uuid, {
|
||||||
action: this?.actionInfo?.action,
|
action: this?.actionInfo?.action,
|
||||||
payload: payload || {},
|
payload: payload || null,
|
||||||
targetContext: context,
|
targetContext: context,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -335,11 +336,14 @@ class ELGSDStreamDeck {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a callback function for when Stream Deck sends data to the property inspector
|
* Registers a callback function for when Stream Deck sends data to the property inspector
|
||||||
|
* @param {string} actionUUID
|
||||||
* @param {function} fn
|
* @param {function} fn
|
||||||
* @param {function} actionUUID
|
|
||||||
* @returns ELGSDStreamDeck
|
* @returns ELGSDStreamDeck
|
||||||
*/
|
*/
|
||||||
onSendToPropertyInspector(fn, actionUUID) {
|
onSendToPropertyInspector(actionUUID, fn) {
|
||||||
|
if (typeof actionUUID != 'string') {
|
||||||
|
throw 'onSendToPropertyInspector requires an actionUUID string.';
|
||||||
|
}
|
||||||
this.on(`${actionUUID}.${Events.sendToPropertyInspector}`, (jsn) => fn(jsn));
|
this.on(`${actionUUID}.${Events.sendToPropertyInspector}`, (jsn) => fn(jsn));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue