This commit is contained in:
yumoqing 2024-10-12 10:40:13 +08:00
parent e0d17cf7e0
commit 97da5deefe

View File

@ -334,17 +334,6 @@ bricks.RTCP2PConnect = class {
console.log('state is connected, data_connect=', console.log('state is connected, data_connect=',
this.opts.data_connect, this.opts.data_connect,
'role=', role); 'role=', role);
if (role == 'requester'){
this.peers[peer.id].dc = pc.createDataChannel('chat', {ordered:true});
var dc = this.peers[peer.id].dc;
await this.dc_created(peer, this.peers[peer.id].dc);
if(this.opts.on_pc_connected){
this.opts.on_pc_connected(peer);
}
console.log('dc created', this.peers[peer.id].dc);
} else {
console.log('87y333333333333333333333333333333333354');
}
} }
} }
@ -399,6 +388,15 @@ bricks.RTCP2PConnect = class {
this.peers[peer.id].role = role; this.peers[peer.id].role = role;
var remoteVideo = new bricks.VideoBox(); var remoteVideo = new bricks.VideoBox();
this.peers[peer.id].video = remoteVideo; this.peers[peer.id].video = remoteVideo;
if (role == 'requester'){
this.peers[peer.id].dc = pc.createDataChannel('chat', {ordered:true});
var dc = this.peers[peer.id].dc;
await this.dc_created(peer, this.peers[peer.id].dc);
if(this.opts.on_pc_connected){
this.opts.on_pc_connected(peer);
}
console.log('dc created', this.peers[peer.id].dc);
}
pc.onicecandidate = this.send_candidate.bind(this, peer); pc.onicecandidate = this.send_candidate.bind(this, peer);
pc.oniceconnectionstatechange = this.ice_statechange.bind(this, peer); pc.oniceconnectionstatechange = this.ice_statechange.bind(this, peer);
pc.onconnectionstatechange = this.connection_statechange.bind(this, peer); pc.onconnectionstatechange = this.connection_statechange.bind(this, peer);