threetobus now uses [UID] template, MessageBus upgraded to cnxId
This commit is contained in:
+1
-1
@@ -99,7 +99,7 @@ class Snaptobus{
|
||||
|
||||
|
||||
processBusEvent(eventType, chan, payload, userId, x){
|
||||
const chanObj = this._curBusConfig.find(item => item.chan==chan)
|
||||
const chanObj = this._curBusConfig.find(item => app.MessageBus.chanMatch(chan, item.chan))
|
||||
if(!chanObj) return
|
||||
const eventObj = chanObj.events.find(item => item.eventName==eventType)
|
||||
if(!eventObj) return
|
||||
|
||||
+2
-19
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user