test-cloudhub-electron-sdk
Version:
cloudhub-electron-sdk
52 lines (51 loc) • 1.46 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
/**
* @module StreamController
* @description 记录目前存在的流
* @author dangmeng
* @date 2020-06-26
* */
const LoggerController_1 = __importDefault(require("./LoggerController"));
const logger = new LoggerController_1.default('CloudHub-streamController-log');
class StreamController {
constructor() {
this.streams = {
video: {},
device: {},
screen: {},
media: {},
movie: {},
};
}
static getInstance() {
if (!this.instance) {
this.instance = new StreamController();
}
return this.instance;
}
setStream(uid, type, stream) {
this.streams[type][uid] = stream;
}
getStream(uid, type) {
return this.streams[type][uid];
}
getUserStream(uid) {
let arr = [];
for (let i in this.streams) {
for (let j in this.streams[i]) {
if (j === uid) {
arr.push(this.streams[i][j]);
}
}
}
return arr;
}
delStream(uid, type) {
delete this.streams[type][uid];
}
}
exports.default = StreamController.getInstance();