WebRTC Base
This commit is contained in:
parent
f34ef6ad22
commit
17eacfcfdc
|
@ -31,20 +31,13 @@ export default class Peer extends EventTarget
|
|||
this.info = new PeerInfo(this);
|
||||
|
||||
this.on('pack',(data:{type?:string,action?:IMessageSymbase,payload?:any}) => {
|
||||
if(data.type == 'rtc')
|
||||
if(data.type == ':rtcbase_pack:')
|
||||
{
|
||||
if(data.action == IMessageSymbase.PayloadRTCBasePack)
|
||||
if(this.rtc)
|
||||
{
|
||||
if(this.rtc)
|
||||
{
|
||||
return this.rtc.emit("input", data.payload)
|
||||
}
|
||||
console.warn("Not active rtc but recaived rtc packs")
|
||||
};
|
||||
if(data.action == IMessageSymbase.PayloadMessagePack)
|
||||
{
|
||||
return this.emit("message", data.payload)
|
||||
return this.rtc.emit("input", data.payload)
|
||||
}
|
||||
return console.warn("Not active rtc but recaived rtc packs")
|
||||
};
|
||||
this.emit("message", data);
|
||||
});
|
||||
|
@ -61,17 +54,12 @@ export default class Peer extends EventTarget
|
|||
})
|
||||
this.rtc.on("output",(payload:object) => {
|
||||
this.send({
|
||||
type: 'rtc',
|
||||
action: IMessageSymbase.PayloadRTCBasePack,
|
||||
type: ':rtcbase_pack:',
|
||||
payload: payload
|
||||
})
|
||||
});
|
||||
this.rtc.on("message",(payload:object) => {
|
||||
this.emit("pack",{
|
||||
type: 'rtc',
|
||||
action: IMessageSymbase.PayloadRTCBasePack,
|
||||
payload: payload
|
||||
})
|
||||
this.emit("pack",payload);
|
||||
});
|
||||
return this.rtc;
|
||||
}
|
||||
|
@ -158,11 +146,7 @@ export default class Peer extends EventTarget
|
|||
to: this.socketId
|
||||
});
|
||||
}else{
|
||||
this.rtc?.sendMessage({
|
||||
type: 'rtc',
|
||||
action: IMessageSymbase.PayloadMessagePack,
|
||||
payload: pack
|
||||
})
|
||||
this.rtc?.sendMessage(pack)
|
||||
}
|
||||
}
|
||||
async forget(){
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue