tons of cursor-shit cleaning, finished implementing cnxId in observer
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user