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.info = new PeerInfo(this);
|
||||||
|
|
||||||
this.on('pack',(data:{type?:string,action?:IMessageSymbase,payload?:any}) => {
|
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)
|
||||||
{
|
|
||||||
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 console.warn("Not active rtc but recaived rtc packs")
|
||||||
};
|
};
|
||||||
this.emit("message", data);
|
this.emit("message", data);
|
||||||
});
|
});
|
||||||
|
@ -61,17 +54,12 @@ export default class Peer extends EventTarget
|
||||||
})
|
})
|
||||||
this.rtc.on("output",(payload:object) => {
|
this.rtc.on("output",(payload:object) => {
|
||||||
this.send({
|
this.send({
|
||||||
type: 'rtc',
|
type: ':rtcbase_pack:',
|
||||||
action: IMessageSymbase.PayloadRTCBasePack,
|
|
||||||
payload: payload
|
payload: payload
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
this.rtc.on("message",(payload:object) => {
|
this.rtc.on("message",(payload:object) => {
|
||||||
this.emit("pack",{
|
this.emit("pack",payload);
|
||||||
type: 'rtc',
|
|
||||||
action: IMessageSymbase.PayloadRTCBasePack,
|
|
||||||
payload: payload
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
return this.rtc;
|
return this.rtc;
|
||||||
}
|
}
|
||||||
|
@ -158,11 +146,7 @@ export default class Peer extends EventTarget
|
||||||
to: this.socketId
|
to: this.socketId
|
||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
this.rtc?.sendMessage({
|
this.rtc?.sendMessage(pack)
|
||||||
type: 'rtc',
|
|
||||||
action: IMessageSymbase.PayloadMessagePack,
|
|
||||||
payload: pack
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async forget(){
|
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