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
+1 -1
View File
@@ -9,7 +9,7 @@ export const dispatchMessage = createDispatchMessage({
eventHandlers,
actionRules(redisCnx) {
const observer = redisCnx.config.observer ?? {}
const arenaChannel = observer.bus?.arena?.actionsChannel
const arenaChannel = observer.arenaActionsChannel
return({
channels: arenaChannel ? [arenaChannel] : [],
})
+3 -3
View File
@@ -1,13 +1,13 @@
export const eventHandlers = {
'arena:lifecycle': {
onYourMarks(msg, chan) {
onYourMarks(msg, chan, sender, cnxId) {
this.observerSrv?.onYourMarks()
},
bigBang(msg, chan) {
bigBang(msg, chan, sender, cnxId) {
this.observerSrv?.onBigBang()
},
simulationStopped(msg, chan) {
simulationStopped(msg, chan, sender, cnxId) {
this.observerSrv?.onSimulationStopped(msg.payload ?? {})
},
},
+1 -1
View File
@@ -11,7 +11,7 @@ export const dispatchMessage = createDispatchMessage({
actionRules(redisCnx) {
const observer = redisCnx.config.observer ?? {}
return({
channels: [observer.observerActionsChannel].filter(Boolean),
channels: [observer.ActionsChannel].filter(Boolean),
})
},
})
+25 -18
View File
@@ -4,66 +4,66 @@ import { Frustum } from '../../frustum.js'
export const actions = {
async action_GETAGENTPOSITION(action, payload, reqid, sender, roles) {
async action_GETAGENTPOSITION(action, payload, reqid, sender, cnxId, roles) {
const reader = this.observerSrv.gpsStorageReader
if(!reader) {
replyToAction(this, { action, reqid, sender, success: false, err: 'GPS storage reader not ready' })
replyToAction(this, { action, reqid, sender, cnxId, success: false, err: 'GPS storage reader not ready' })
return
}
if(!this.observerSrv.isLive()) {
replyToAction(this, { action, reqid, sender, success: false, err: 'Simulation not live' })
replyToAction(this, { action, reqid, sender, cnxId, success: false, err: 'Simulation not live' })
return
}
const agentId = payload?.agentId
if(!agentId || typeof(agentId) !== 'string') {
replyToAction(this, { action, reqid, sender, success: false, err: 'Missing or invalid agentId' })
replyToAction(this, { action, reqid, sender, cnxId, success: false, err: 'Missing or invalid agentId' })
return
}
const at = parseSimTime(payload, () => this.observerSrv.now())
if(at === null) {
replyToAction(this, { action, reqid, sender, success: false, err: 'Invalid simulation time' })
replyToAction(this, { action, reqid, sender, cnxId, success: false, err: 'Invalid simulation time' })
return
}
const agent = await reader.getAgentPosition(agentId, at)
if(!agent) {
replyToAction(this, { action, reqid, sender, success: false, err: `Unknown agent: ${agentId}` })
replyToAction(this, { action, reqid, sender, cnxId, success: false, err: `Unknown agent: ${agentId}` })
return
}
replyToAction(this, { action, reqid, sender, success: true, payload: { agent } })
replyToAction(this, { action, reqid, sender, cnxId, success: true, payload: { agent } })
},
async action_GETAGENTSINFRUSTUM(action, payload, reqid, sender, roles) {
async action_GETAGENTSINFRUSTUM(action, payload, reqid, sender, cnxId, roles) {
const registry = this.observerSrv.requestorRegistry
if(!registry) {
replyToAction(this, { action, reqid, sender, success: false, err: 'Requestor registry not ready' })
replyToAction(this, { action, reqid, sender, cnxId, success: false, err: 'Requestor registry not ready' })
return
}
if(!this.observerSrv.isLive()) {
replyToAction(this, { action, reqid, sender, success: false, err: 'Simulation not live' })
replyToAction(this, { action, reqid, sender, cnxId, success: false, err: 'Simulation not live' })
return
}
const frustum = Frustum.fromPlanes(payload?.planes)
if(!frustum) {
replyToAction(this, { action, reqid, sender, success: false, err: 'Missing or invalid frustum planes (expected 6)' })
replyToAction(this, { action, reqid, sender, cnxId, success: false, err: 'Missing or invalid frustum planes (expected 6)' })
return
}
const at = parseSimTime(payload, () => this.observerSrv.now())
if(at === null) {
replyToAction(this, { action, reqid, sender, success: false, err: 'Invalid simulation time' })
replyToAction(this, { action, reqid, sender, cnxId, success: false, err: 'Invalid simulation time' })
return
}
const result = await registry.evaluateOnce({ frustum, t: at })
if(!result.ok) {
replyToAction(this, { action, reqid, sender, success: false, err: result.err })
replyToAction(this, { action, reqid, sender, cnxId, success: false, err: result.err })
return
}
@@ -71,6 +71,7 @@ export const actions = {
action,
reqid,
sender,
cnxId,
success: true,
payload: {
agents: result.agents,
@@ -79,24 +80,29 @@ export const actions = {
})
},
async action_SUBSCRIBEFRUSTUM(action, payload, reqid, sender, roles) {
async action_SUBSCRIBEFRUSTUM(action, payload, reqid, sender, cnxId, roles) {
const registry = this.observerSrv.requestorRegistry
if(!registry) {
replyToAction(this, { action, reqid, sender, success: false, err: 'Requestor registry not ready' })
replyToAction(this, { action, reqid, sender, cnxId, success: false, err: 'Requestor registry not ready' })
return
}
if(!this.observerSrv.isLive()) {
replyToAction(this, { action, reqid, sender, success: false, err: 'Simulation not live' })
replyToAction(this, { action, reqid, sender, cnxId, success: false, err: 'Simulation not live' })
return
}
const result = await registry.subscribeFrustum(sender, {
if(!cnxId || typeof(cnxId) !== 'string') {
replyToAction(this, { action, reqid, sender, cnxId, success: false, err: 'Missing or invalid cnxId' })
return
}
const result = await registry.subscribeFrustum(cnxId, {
planes: payload?.planes,
frequency: payload?.frequency,
})
if(!result.ok) {
replyToAction(this, { action, reqid, sender, success: false, err: result.err })
replyToAction(this, { action, reqid, sender, cnxId, success: false, err: result.err })
return
}
@@ -104,6 +110,7 @@ export const actions = {
action,
reqid,
sender,
cnxId,
success: true,
payload: {
frequency: result.frequency,
+4 -3
View File
@@ -2,16 +2,17 @@ import { replyToAction } from '../../../bus/publishActionReply.js'
export const actions = {
async action_RELOADCONFIG(action, payload, reqid, sender, roles) {
async action_RELOADCONFIG(action, payload, reqid, sender, cnxId, roles) {
this.reloadAccessRights()
replyToAction(this, { action, reqid, sender, success: true })
replyToAction(this, { action, reqid, sender, cnxId, success: true })
},
async action_GETCONFIG(action, payload, reqid, sender, roles) {
async action_GETCONFIG(action, payload, reqid, sender, cnxId, roles) {
replyToAction(this, {
action,
reqid,
sender,
cnxId,
success: true,
payload: this.getAccessRights(),
})