export function construct(redisCnx) { const tickMs = redisCnx.gpsSrv?.gpsConfig.collisionTickMs ?? 100 setInterval(() => { redisCnx.gpsSrv?.tickArena() }, tickMs) } export const eventHandlers = { 'arena:lifecycle': { onYourMarks(msg, chan, sender, cnxId) { const srv = this.gpsSrv if(!srv) return srv.onYourMarks(msg.payload ?? {}).catch(err => { console.error(`[${this.redisId}] onYourMarks failed:`, err) srv.publishReadyToStart({ success: false, err: err.message ?? 'onYourMarks failed' }) }) }, bigBang(msg, chan, sender, cnxId) { this.gpsSrv?.onBigBang(msg.payload ?? {}) }, simulationPaused(msg, chan, sender, cnxId) { this.gpsSrv?.onSimulationPaused(msg.payload ?? {}) }, simulationResumed(msg, chan, sender, cnxId) { this.gpsSrv?.onSimulationResumed(msg.payload ?? {}) }, simulationStopped(msg, chan, sender, cnxId) { const srv = this.gpsSrv if(!srv) return srv.onSimulationStopped(msg.payload ?? {}).catch(err => { console.error(`[${this.redisId}] simulationStopped failed:`, err) }) }, }, }