first GodDaemons group commit

This commit is contained in:
STEINNI
2026-06-12 17:05:35 +00:00
commit 932b6e4752
20 changed files with 1655 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
import { methods as utilities, construct as utilitiesConstruct } from './utilities.js'
import { methods as positions } from './positions.js'
export const afterLoginMethods = [
utilitiesConstruct,
]
export const meshActions = {
...utilities,
...positions,
}
+146
View File
@@ -0,0 +1,146 @@
import { publishActionReply, parseAt } from '../../actionsHelper.js'
export const methods = {
/* Event-Rx:
{
"action": "GETAGENTPOSITION",
"reqid": "6az5e4r6a",
"payload": {
"agentId": "agent42",
"at": "2026-06-07T12:00:00.000Z"
}
}
Event-Tx:
{
"action": "GETAGENTPOSITION",
"success": true,
"reqid": "6az5e4r6a",
"payload": {
"agent": {
"id": "agent42",
"position": { "x": 1, "y": 2, "z": 3 },
"vector": { "x": 0, "y": 0, "z": 0 },
"since": 1717750800,
"generation": 2,
"at": "2026-06-07T12:00:00.000Z"
}
}
}
*/
async action_GETAGENTPOSITION(action, payload, reqid, sender, roles) {
const replyOpts = {
action,
reqid,
sender,
replyChannel: this.config.gps.gpsActionsReply,
}
if(!this.accessRights.canDo(roles, action)) {
publishActionReply(this, { ...replyOpts, reply: {
success: false,
err: 'Unauthorized action !',
} })
return
}
const agentId = payload?.agentId
if(!agentId || typeof(agentId) !== 'string') {
publishActionReply(this, { ...replyOpts, reply: {
success: false,
err: 'Missing or invalid agentId',
} })
return
}
const at = parseAt(payload, () => this.gpsSrv.now())
if(at === null) {
publishActionReply(this, { ...replyOpts, reply: {
success: false,
err: 'Invalid at timestamp',
} })
return
}
const agent = this.gpsSrv.getAgentPosition(agentId, at)
if(!agent) {
publishActionReply(this, { ...replyOpts, reply: {
success: false,
err: `Unknown agent: ${agentId}`,
} })
return
}
publishActionReply(this, { ...replyOpts, reply: {
success: true,
payload: { agent },
} })
},
/* Event-Rx:
{
"action": "GETAGENTSINPRISM",
"reqid": "6az5e4r6a",
"payload": {
"prism": {
"xMin": -10, "xMax": 10,
"yMin": -10, "yMax": 10,
"zMin": 0, "zMax": 5
},
"at": "2026-06-07T12:00:00.000Z"
}
}
Event-Tx:
{
"action": "GETAGENTSINPRISM",
"success": true,
"reqid": "6az5e4r6a",
"payload": {
"agents": [ ... ],
"at": "2026-06-07T12:00:00.000Z"
}
}
*/
async action_GETAGENTSINPRISM(action, payload, reqid, sender, roles) {
const replyOpts = {
action,
reqid,
sender,
replyChannel: this.config.gps.gpsActionsReply,
}
if(!this.accessRights.canDo(roles, action)) {
publishActionReply(this, { ...replyOpts, reply: {
success: false,
err: 'Unauthorized action !',
} })
return
}
const prism = payload?.prism
if(!this.gpsSrv.isValidPrism(prism)) {
publishActionReply(this, { ...replyOpts, reply: {
success: false,
err: 'Missing or invalid prism bounds',
} })
return
}
const at = parseAt(payload, () => this.gpsSrv.now())
if(at === null) {
publishActionReply(this, { ...replyOpts, reply: {
success: false,
err: 'Invalid at timestamp',
} })
return
}
const agents = this.gpsSrv.getAgentsInPrism(prism, at)
publishActionReply(this, { ...replyOpts, reply: {
success: true,
payload: {
agents,
at: new Date(at * 1000).toISOString(),
},
} })
},
}
+109
View File
@@ -0,0 +1,109 @@
import { publishActionReply } from '../../actionsHelper.js'
export const construct = (redisCnx) => {
// console.log('Hello after login from utilities...')
// redisCnx.v42=0
// setInterval(redisCnx.move4243.bind(redisCnx), 200)
}
export const methods = {
/* Event-Rx:
{
"action": "TIME"
"reqid": "6az5e4r6a"
}
Event-Tx:
{
"action": "TIME",
"success": true,
"payload" : {
gpsTime: "2022-09-01T14:42:22.603Z",
redisTime: "2022-09-01T14:42:22.603Z"
},
"reqid": "6az5e4r6a"
}
*/
async action_TIME(action, payload, reqid, sender, roles){
publishActionReply(this, {
action,
reqid,
sender,
replyChannel: this.config.gps.gpsActionsReply,
reply: {
success: true,
payload: {
gpsTime: new Date().toISOString(),
redisTime: await this.redisClient.time(),
},
},
})
},
/* Event-Rx:
{
"action": "RELOADCONFIG"
"reqid": "6az5e4r6a"
}
Event-Tx:
{
"action": "RELOADCONFIG",
"success": true,
"reqid": "6az5e4r6a"
}
*/
async action_RELOADCONFIG(action, payload, reqid, sender, roles){
const replyOpts = {
action,
reqid,
sender,
replyChannel: this.config.gps.gpsActionsReply,
}
if(!this.accessRights.canDo(roles, action)) {
publishActionReply(this, { ...replyOpts, reply: {
success: false,
err: 'Unauthorized action !',
} })
return
}
this.reloadAccessRights()
publishActionReply(this, { ...replyOpts, reply: {
success: true,
} })
},
/* Event-Rx:
{
"action": "GETCONFIG"
"reqid": "6az5e4r6a"
}
Event-Tx:
{
"action": "GETCONFIG",
"success": true,
"reqid": "6az5e4r6a",
payload: { ...the access rights, and roles... }
}
*/
async action_GETCONFIG(action, payload, reqid, sender, roles){
const replyOpts = {
action,
reqid,
sender,
replyChannel: this.config.gps.gpsActionsReply,
}
if(!this.accessRights.canDo(roles, action)) {
publishActionReply(this, { ...replyOpts, reply: {
success: false,
err: 'Unauthorized action !',
} })
return
}
publishActionReply(this, { ...replyOpts, reply: {
success: true,
payload: this.getAccessRights(),
} })
},
}