bugfix
This commit is contained in:
parent
d1937661ed
commit
4f753548c7
@ -208,16 +208,19 @@ bricks.RTCP2PConnect = class {
|
||||
return this.signal_handlers[typ];
|
||||
}
|
||||
|
||||
async p2pconnect(peer){
|
||||
async p2pconnect(peer, role){
|
||||
await this.getLocalStream();
|
||||
var p = this.peers[peer.id];
|
||||
if (!p){
|
||||
await this.createPeerConnection(peer);
|
||||
await this.createPeerConnection(peer, role);
|
||||
} else {
|
||||
aconsole.log(peer, 'connect exists', this);
|
||||
}
|
||||
console.log('p2pconnect() called, this=', this, 'peer=', peer);
|
||||
await this.send_offer(peer);
|
||||
if (role=='requester'){
|
||||
await this.send_offer(peer);
|
||||
}
|
||||
|
||||
}
|
||||
async h_sessioncreated(data){
|
||||
if (this.opts.peer_info){
|
||||
@ -236,13 +239,13 @@ bricks.RTCP2PConnect = class {
|
||||
msgto:data.msgfrom
|
||||
};
|
||||
this.signaling_send(d);
|
||||
await this.p2pconnect(data.msgfrom);
|
||||
await this.p2pconnect(data.msgfrom, 'responser');
|
||||
return;
|
||||
}
|
||||
this.dispatch('callrequest', data.msgfrom);
|
||||
}
|
||||
async h_callaccepted(data){
|
||||
await this.p2pconnect(data.msgfrom);
|
||||
await this.p2pconnect(data.msgfrom, 'requester');
|
||||
}
|
||||
async h_offer(data){
|
||||
console.log('h_offer(), this=', this, 'peer=', data.msgfrom);
|
||||
@ -256,6 +259,10 @@ bricks.RTCP2PConnect = class {
|
||||
answer:pc.localDescription,
|
||||
msgto:data.msgfrom
|
||||
});
|
||||
if (this.peers[data.msgfrom.id].role == 'responser'){
|
||||
await this.send_offer(peer);
|
||||
}
|
||||
|
||||
}
|
||||
async h_answer(data){
|
||||
var desc = new RTCSessionDescription(data.answer);
|
||||
@ -365,7 +372,7 @@ bricks.RTCP2PConnect = class {
|
||||
await this.opts.on_dc_close(dc);
|
||||
}
|
||||
}
|
||||
async createPeerConnection(peer){
|
||||
async createPeerConnection(peer, role){
|
||||
const configuration = {
|
||||
iceServers:this.opts.ice_servers
|
||||
}
|
||||
@ -378,6 +385,7 @@ bricks.RTCP2PConnect = class {
|
||||
}
|
||||
this.peers[peer.id] = bricks.extend({}, peer);
|
||||
this.peers[peer.id].pc = pc;
|
||||
this.peers[peer.id].role = role;
|
||||
var remoteVideo = new bricks.VideoBox();
|
||||
this.peers[peer.id].video = remoteVideo;
|
||||
pc.onicecandidate = this.send_candidate.bind(this, peer);
|
||||
|
Loading…
Reference in New Issue
Block a user