threetobus now uses [UID] template, MessageBus upgraded to cnxId

This commit is contained in:
STEINNI
2026-06-26 21:56:19 +00:00
parent aefa5ab147
commit cf292031fd
4 changed files with 81 additions and 89 deletions
+2 -19
View File
@@ -33,31 +33,14 @@ export class Threetobus{
if(this._frustumWatching) this._scheduleFrustumResubscribe()
}
resolveSubscriberChan(chanTemplate) {
if(typeof(chanTemplate) !== 'string') return(null)
const uid = app.User?.identity?.uuid
if(!uid) return(null)
return(chanTemplate.replace(/\[UID\]/g, uid).replace(/\{uid\}/g, uid))
}
_resolvedEventsMapping() {
if(!Array.isArray(this._stagedEventsMapping)) return([])
return(this._stagedEventsMapping.map(chanObj => {
const chan = this.resolveSubscriberChan(chanObj.chan)
if(!chan) return(null)
return({ ...chanObj, chan })
}).filter(Boolean))
}
get EventsMapping() { return this._stagedEventsMapping }
get liveEventsMapping() { return this._curEventsMapping }
set EventsMapping(newConfig) { this._stagedEventsMapping = newConfig }
async commitConfig(){
const resolvedMapping = this._resolvedEventsMapping()
const chansToAdd = []
const chansToKeep = []
for(const chanObj of resolvedMapping){
for(const chanObj of this._stagedEventsMapping){
if(this._curEventsMapping.map(item => item.chan).includes(chanObj.chan)) chansToKeep.push(chanObj)
else chansToAdd.push(chanObj)
}
@@ -91,7 +74,7 @@ export class Threetobus{
app.MessageBus.removeBusListener(eventToDel.eventName, this.processBusEvent.bind(this, eventToDel.eventName), 'threetobus')
}
this._curEventsMapping = this.deepClone(resolvedMapping)
this._curEventsMapping = this.deepClone(this._stagedEventsMapping)
}
deepClone(obj) { // Needed because structuredClone doesn't take functions (and we have transformers)