UNPKG

yimultiscreenserver-sdk-web

Version:

YiMultiScreenServer SDK for Web

106 lines 3.81 kB
import { CastSessionVO } from "../vo/cast/CastSessionVO"; import { ControllerDeviceVO } from "../vo/device/ControllerDeviceVO"; import { DisplayReportVO } from "../vo/report/DisplayReportVO"; export class GlobalCache { constructor() { this.onlineDisplays = new Map(); this.connectedDisplays = new Map(); this.displayReports = new Map(); this.castSessions = new Map(); this.controllers = new Map(); } addOnlineDisplay(displayDeviceId, displayCode, report) { this.onlineDisplays.set(displayDeviceId, displayCode); this.displayReports.set(displayCode, report); } removeOnlineDisplay(displayDeviceId, displayCode) { this.displayReports.delete(displayCode); this.onlineDisplays.delete(displayDeviceId); } clearOnlineDisplay() { this.displayReports.clear(); this.onlineDisplays.clear(); } getOnlineDisplayByID(displayDeviceId) { let displayCode = this.onlineDisplays.get(displayDeviceId); if (undefined === displayCode || null === displayCode) { return null; } return this.getOnlineDisplayByCode(displayCode); } getOnlineDisplayByCode(displayCode) { let ori = this.displayReports.get(displayCode); if (undefined === ori || null === ori) { return null; } return DisplayReportVO.copy(ori); } addConnectedDisplay(controllerGuid, displayCode, report) { this.connectedDisplays.set(controllerGuid, displayCode); this.onlineDisplays.set(report.displayDevice.displayDeviceId, displayCode); this.displayReports.set(displayCode, report); } removeConnectedDisplay(controllerGuid, displayCode) { this.connectedDisplays.delete(controllerGuid); } clearConnectedDisplay() { this.connectedDisplays.clear(); } getConnectedDisplayByID(controllerGuid) { let displayCode = this.connectedDisplays.get(controllerGuid); if (undefined === displayCode || null === displayCode) { return null; } return this.getConnectedDisplayByCode(displayCode); } getConnectedDisplayByCode(displayCode) { return this.getOnlineDisplayByCode(displayCode); } addCastSession(castSessionId, session) { this.castSessions.set(castSessionId, session); } removeCastSession(castSessionId) { this.castSessions.delete(castSessionId); } castSessionValues() { return this.castSessions.values(); } getCastSession(castSessionId) { let session = new CastSessionVO(); if (0 === this.castSessions.size || !this.castSessions.has(castSessionId)) { return null; } let ori = this.castSessions.get(castSessionId); session.castSessionId = ori.castSessionId; session.displayCode = ori.displayCode; session.guid = ori.guid; session.castType = ori.castType; ; session.castProtocol = ori.castProtocol; return session; } clearCastSessions() { this.castSessions.clear(); } addControllerDevice(guid, device) { this.controllers.set(guid, device); } removeControllerDevice(guid) { this.controllers.delete(guid); } getControllerDevice(guid) { let copy = new ControllerDeviceVO(); if (0 === this.controllers.size || !this.controllers.has(guid)) { return null; } let ori = this.controllers.get(guid); copy.guid = ori.guid; copy.controllerDeviceType = ori.controllerDeviceType; copy.ip = ori.ip; copy.gateway = ori.gateway; copy.mask = ori.mask; copy.outIp = ori.outIp; return copy; } } //# sourceMappingURL=GlobalCache.js.map