UNPKG

@isaac-platform/isaac-integration-sdk

Version:

A Typescript SDK for integrating with ISAAC

60 lines (58 loc) 2.44 kB
import isaacConnection from "./controller/isaac.js"; import * as isaacPanels from "./panels/index.js"; import * as isaacVariables from "./variables/index.js"; import * as isaacBackups from "./backups/index.js"; import * as isaacSchedule from "./schedule/index.js"; import * as isaacObjects from "./objects/index.js"; import * as isaacLogging from "./logging/index.js"; import * as isaacPlayers from "./players/index.js"; import { Heartbeat } from "./heartbeat.js"; import { Player } from "./players/Player"; export class ISAACServer { // public subsystem: isaacSubsystems.subsystemController /* Pseudocode: myIsaac.subsystems.nrDemo2.variables.update('temperature', 50); myIsaac.variables.update('nrDemo2', 'temperature', 50); myIsaac.subsystems.nrDemo2.variables.temperature.update(50); ???? The variables of a subsystem should be a subset of the main variables object such that they can be updated in various "styles" without creating duplicate references which may become out of sync. */ constructor(ipAddress, moduleID, authToken) { this.isActive = false; this.startServices = () => { if (this.isaacConn.isReady) { this.heartbeat.start(); this.schedule.start(); this.isActive = true; } else { console.error('ISAAC SDK: No connection details provided.'); } }; this.stopServices = () => { this.heartbeat.stop(); this.schedule.stop(); this.isActive = false; }; this.isaacConn = isaacConnection; isaacConnection.setConnectionDetails({ ip: ipAddress, subsystemID: moduleID, apiToken: authToken }); this.panels = new isaacPanels.panelController(); this.variables = new isaacVariables.variableController(); this.backups = new isaacBackups.BackupController(); this.schedule = new isaacSchedule.ScheduleController(); this.objects = new isaacObjects.ObjectController(); this.logger = new isaacLogging.Logger(); this.players = new isaacPlayers.PlayerController(); this.player = new Player(); this.heartbeat = new Heartbeat(); } } export default class ISAAC { static connection(ipAddress, moduleName, apiToken) { return new ISAACServer(ipAddress, moduleName, apiToken); } }