UNPKG

test-cloudhub-electron-sdk

Version:

cloudhub-electron-sdk

53 lines (52 loc) 1.5 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); /** * @module RoomController * @description 记录目前存在的用户 * @author dangmeng * @date 2020-06-26 * */ const LoggerController_1 = __importDefault(require("./LoggerController")); const logger = new LoggerController_1.default('CloudHub-roomController-log'); class RoomController { constructor() { this.myself = {}; this.users = {}; } static getInstance() { if (!this.instance) { this.instance = new RoomController(); } return this.instance; } getMyself() { return this.myself; } setMyself(data = {}) { this.myself = Object.assign(this.myself, data); } getUser(uid) { return this.users[uid]; } getUsers() { return this.users; } setUser(uid, data = {}) { this.users[uid] = data; } setUserProperty(uid, properties = {}) { if (!uid) return; if (uid === this.myself.uid) { this.myself = Object.assign(this.myself, properties); } this.users[uid] = Object.assign(this.users[uid] || {}, properties); } delUser(uid) { delete this.users[uid]; } } exports.default = RoomController.getInstance();