import Room from "./Room"; export class RoomInfo { public room : Room; public info : {[key:string]: any} = {}; constructor(room : Room){ this.room = room; }; public async fetch(name?:string) { if(name) { let rinfo = await this.room.mwse.EventPooling.request(({ type: "room/getinfo", roomId: this.room.roomId, name })); if(rinfo.status == "success") { this.info = rinfo.info; }else console.warn(rinfo.message); }else{ let rinfo = await this.room.mwse.EventPooling.request(({ type: "peer/info", peer: this.room.roomId })); if(rinfo.status == "success") { this.info = rinfo.info; }else console.warn(rinfo.message); }; return this.info; } public set(name: string, value: string | number) { this.info[name] = value; this.room.mwse.WSTSProtocol.SendOnly({ type: "room/setinfo", roomId: this.room.roomId, name, value }); } public get(name?:string) { return name ? this.info[name] : this.info; } }