import EventTarget from "./EventTarget"; import MWSE from "./index"; interface IPeerOptions{ }; interface IPeerMetadata{ }; export default class Peer extends EventTarget { public mwse : MWSE; public options! : IPeerOptions; public socketId? : string; public selfSocket : boolean = false; public active : boolean = false; constructor(wsts:MWSE){ super(); this.mwse = wsts; } setPeerOptions(options: string | IPeerOptions){ if(typeof options == "string") { this.setSocketId(options) }else{ this.options = options; } } setSocketId(uuid: string){ this.socketId = uuid; } async metadata() : Promise { if(this.socketId == 'me') { let result = await this.mwse.EventPooling.request({ type:'my/socketid' }); this.selfSocket = true; this.active ||= true; this.socketId = result; this.emit('scope'); this.activeScope = true; return result; } } async enablePairAuth(){ await this.mwse.EventPooling.request({ type:'auth/pair-system', value: 'everybody' }); } async disablePairAuth(){ await this.mwse.EventPooling.request({ type:'auth/pair-system', value: 'disable' }); } async send(pack: any){ await this.mwse.EventPooling.request({ type:'pack/to', pack, to: this.socketId }); } }