tons of cursor-shit cleaning, finished implementing cnxId in observer

This commit is contained in:
STEINNI
2026-06-27 17:24:41 +00:00
parent 4c9e989bda
commit a1dba5060a
28 changed files with 213 additions and 224 deletions
+13 -29
View File
@@ -7,10 +7,12 @@ export class observerServer {
constructor(configHelper, allRediscnx, debug) {
this.configHelper = configHelper
this.observerConfig = configHelper.config
this.rootConfig = configHelper.config
this.observerConfig = configHelper.config.observer ?? {}
this.gpsConfig = configHelper.config.gps ?? {}
this.allRediscnx = allRediscnx
this.debug = debug
this.accessRights = new AccesRights(this.observerConfig, debug)
this.accessRights = new AccesRights(this.rootConfig, debug)
this.arenaCnx = null
this.arenaCnxs = []
this.systemCnx = null
@@ -20,27 +22,8 @@ export class observerServer {
this.bigBangEpoch = null
}
getObserverSettings() {
const observer = this.observerConfig.observer ?? {}
return({
senderId: observer.senderId ?? 'observer',
scanIntervalMs: observer.scanIntervalMs ?? 300,
frustumEventsChannel: observer.observerFrustumEventsChannel
?? 'system:observer:subscribed[UID]:agents',
lifecycle: {
arenaChannel: observer.lifecycle?.arenaChannel ?? 'arena:lifecycle',
godsReadyChannel: observer.lifecycle?.godsReadyChannel ?? 'arena:gods:ready',
},
})
}
getGpsStorageSettings() {
const gps = this.observerConfig.gps ?? {}
return(gps.GPSstorage ?? null)
}
initGpsStorageReader() {
const gpsStorage = this.getGpsStorageSettings()
const gpsStorage = this.gpsConfig.GPSstorage
if(gpsStorage && this.systemCnx) {
this.gpsStorageReader = new GpsStorageReader(this.systemCnx, gpsStorage, this.debug)
this.initRequestorRegistry()
@@ -49,7 +32,7 @@ export class observerServer {
initRequestorRegistry() {
if(!this.gpsStorageReader || this.requestorRegistry) return
const { scanIntervalMs } = this.getObserverSettings()
const { scanIntervalMs } = this.observerConfig
this.requestorRegistry = new RequestorRegistry(
this.gpsStorageReader,
() => this.now(),
@@ -67,9 +50,9 @@ export class observerServer {
if(!this.systemCnx || !subscriberId) return
if(!Array.isArray(agents) || !agents.length) return
const { frustumEventsChannel } = this.getObserverSettings()
const chan = frustumEventsChannel.replace(/\[UID\]/g, subscriberId)
const senderId = this.getObserverSettings().senderId
const chan = this.observerConfig.FrustumEventsChannel
.replace(/\[CUID\]/g, subscriberId)
const senderId = this.observerConfig.senderId
for(const agent of agents) {
if(!agent?.id || !agent?.position) continue
@@ -77,6 +60,7 @@ export class observerServer {
await this.systemCnx.redisPublish(chan, {
eventType: 'move',
sender: senderId,
cnxId: this.systemCnx.cnxId,
payload: {
aid: agent.id,
coords: {
@@ -147,12 +131,12 @@ export class observerServer {
async reloadAccessRights() {
await this.configHelper.refreshAccessRights()
this.observerConfig.accessRights = this.configHelper.config.accessRights
this.accessRights.refreshAccessRights(this.observerConfig)
this.rootConfig.accessRights = this.configHelper.config.accessRights
this.accessRights.refreshAccessRights(this.rootConfig)
}
getAccessRights() {
return(this.observerConfig.accessRights)
return(this.rootConfig.accessRights)
}
}