This commit is contained in:
yumoqing 2024-10-11 13:58:19 +08:00
parent 9e611ee75e
commit ae79a891d7

View File

@ -182,6 +182,7 @@ bricks.RTCP2PConnect = class {
*/
constructor(signaling, session, opts){
this.id = bricks.uuid();
this.signaling = signaling;
this.session = session;
this.requester = false;
@ -208,8 +209,13 @@ bricks.RTCP2PConnect = class {
async p2pconnect(peer){
await this.getLocalStream();
await this.createPeerConnection(peer);
console.log('p2pconnect() called, this=', this);
var p = this.peers[peer.id];
if (!p){
await this.createPeerConnection(peer);
} else {
aconsole.log(peer, 'connect exists', this);
}
console.log('p2pconnect() called, this=', this, 'peer=', peer);
}
async h_sessioncreated(data){
if (this.opts.peer_info){
@ -238,7 +244,7 @@ bricks.RTCP2PConnect = class {
await this.send_offer(data.msgfrom);
}
async h_offer(data){
console.log('send_offer(), peers=', this.peers, 'peer=', data.msgfrom);
console.log('h_offer(), this=', this 'peer=', data.msgfrom);
var pc = this.peers[data.msgfrom.id].pc;
var offer = new RTCSessionDescription(data.offer);
await pc.setRemoteDescription(offer);