import { replyToAction } from '../../../bus/publishActionReply.js' import { isValidUuid } from '../../simRepository.js' export const actions = { async action_STARTSIMULATION(action, payload, reqid, sender, roles) { if(!isValidUuid(sender)) { replyToAction(this, { action, reqid, sender, success: false, err: 'Missing or invalid sender (user UUID)' }) return } if(!payload?.simulationUuid) { replyToAction(this, { action, reqid, sender, success: false, err: 'Missing simulationUuid' }) return } const result = await this.maestroSrv.startSimulation(sender, payload) if(!result.ok) { replyToAction(this, { action, reqid, sender, success: false, err: result.err }) return } replyToAction(this, { action, reqid, sender, success: true, payload: { simulationId: result.simulationId, keyframeId: result.keyframeId, infraId: result.infraId, agentIds: result.agentIds, }, }) }, async action_STOPSIMULATION(action, payload, reqid, sender, roles) { if(!isValidUuid(sender)) { replyToAction(this, { action, reqid, sender, success: false, err: 'Missing or invalid sender (user UUID)' }) return } if(!payload?.simulationUuid) { replyToAction(this, { action, reqid, sender, success: false, err: 'Missing simulationUuid' }) return } const result = await this.maestroSrv.stopSimulation(sender, payload) if(!result.ok) { replyToAction(this, { action, reqid, sender, success: false, err: result.err }) return } replyToAction(this, { action, reqid, sender, success: true, payload: { simulationId: result.simulationId }, }) }, }