This commit is contained in:
yumoqing 2024-08-21 15:50:30 +08:00
parent 321e25e309
commit 20f92e3bea

View File

@ -74,7 +74,6 @@ bricks.RTCClient = class extends bricks.VBox {
this.choose_peer(); this.choose_peer();
} else { } else {
this.call_close(); this.call_close();
this.phone.set_state('free');
} }
} }
choose_peer(){ choose_peer(){
@ -218,7 +217,7 @@ bricks.RTCClient = class extends bricks.VBox {
async signaling_message_handle(event){ async signaling_message_handle(event){
var datapkg = JSON.parse(event.data); var datapkg = JSON.parse(event.data);
var d = datapkg.data; var d = datapkg.data;
console.log('data received from server', 'd=', d, d.type); console.log('data received from server', 'd=', d);
switch (d.type){ switch (d.type){
case 'onlineList': case 'onlineList':
this.onlineList = d.onlineList; this.onlineList = d.onlineList;
@ -250,10 +249,9 @@ bricks.RTCClient = class extends bricks.VBox {
} }
break; break;
case 'iceCandidate': case 'iceCandidate':
console.log('iceCandidate: d.from=', d.from, 'peer_info=', this.peer_info);
if (d.from.id == this.peer_info.id){ if (d.from.id == this.peer_info.id){
var candidate = new RTCIceCandidate(d.candidate); # var candidate = new RTCIceCandidate(d.candidate);
await this.pc.addIceCandidate(candidate); await this.pc.addIceCandidate(d.candidate);
console.log('iceCandidate branch exe'); console.log('iceCandidate branch exe');
} }
break; break;
@ -282,8 +280,7 @@ bricks.RTCClient = class extends bricks.VBox {
await this.getLocalStream(); await this.getLocalStream();
const configuration = { const configuration = {
iceServers: [ iceServers: [
{ urls: this.ice_url }, { urls: this.ice_url }
{ urls: 'stun:stunserver2024.stunprotocol.org:3478' }
] ]
}; };
this.pc = new RTCPeerConnection(configuration); this.pc = new RTCPeerConnection(configuration);