bugfix
This commit is contained in:
parent
982f5eedc5
commit
9dab708301
@ -1,5 +1,62 @@
|
||||
var bricks = window.bricks || {}
|
||||
|
||||
bricks.Signaling = class {
|
||||
/*
|
||||
{
|
||||
signaling_url:
|
||||
info:
|
||||
multiple:false
|
||||
}
|
||||
*/
|
||||
constructor(opts){
|
||||
this.signaling_url = opts.signaling_url;
|
||||
this.info = opts.info;
|
||||
this.peers = [];
|
||||
this.sessions = {};
|
||||
this.init_websocket();
|
||||
}
|
||||
init_websocket(){
|
||||
this.socket = new WebSocket(this.signaling_url);
|
||||
this.socket.onmessage = this.signaling_message_handle.bind(this);
|
||||
this.socket.onopen = this.signaling_login.bind(this);
|
||||
this.socket.onclose = function(){
|
||||
this.init_websockset();
|
||||
};
|
||||
this.socket.onerror = function(){
|
||||
try {
|
||||
this.socket.close();
|
||||
} catch(e){
|
||||
console.log('error,', e);
|
||||
}
|
||||
};
|
||||
}
|
||||
login(){
|
||||
var d = {
|
||||
type:'login',
|
||||
info:this.info
|
||||
}
|
||||
this.send_datad);
|
||||
}
|
||||
|
||||
logout(){
|
||||
var d= {
|
||||
type:'logout',
|
||||
info:this.info
|
||||
}
|
||||
this.send_data(d);
|
||||
}
|
||||
send_data(d){
|
||||
var s = JSON.stringify(d);
|
||||
self.socket.send(s);
|
||||
}
|
||||
socket_send(s){
|
||||
self.socket.send(s);
|
||||
}
|
||||
}
|
||||
|
||||
bricks.RTCSession = class extends bricks.VBox {
|
||||
|
||||
}
|
||||
bricks.VideoBox = class extends bricks.JsWidget {
|
||||
create(){
|
||||
this.dom_element = this._create('video');
|
||||
@ -77,8 +134,19 @@ bricks.RTCClient = class extends bricks.VBox {
|
||||
this.socket = new WebSocket(this.signaling_url);
|
||||
this.socket.onmessage = this.signaling_message_handle.bind(this);
|
||||
this.socket.onopen = this.signaling_login.bind(this);
|
||||
this.socket.onclose = function(){ console.log('888888 this.socket is closed', this.socket); };
|
||||
this.socket.onerror = null;
|
||||
this.socket.onclose = function(){
|
||||
console.log('888888 this.socket is closed', this.socket);
|
||||
if (this.parent){
|
||||
this.init_websockset();
|
||||
}
|
||||
};
|
||||
this.socket.onerror = function(){
|
||||
try {
|
||||
this.socket.close();
|
||||
} catch(e){
|
||||
console.log('error,', e);
|
||||
}
|
||||
};
|
||||
}
|
||||
build_head(){
|
||||
var box = new bricks.HBox({height:'50px'});
|
||||
@ -390,6 +458,11 @@ bricks.RTCClient = class extends bricks.VBox {
|
||||
});
|
||||
w.open();
|
||||
this.call_close();
|
||||
this.dispatch('disconnected', this.peer_info);
|
||||
return;
|
||||
}
|
||||
if (this.pc.connectionState == 'connected'){
|
||||
this.dispatch('connected', this.peer_info);
|
||||
}
|
||||
}
|
||||
ice_g_statechange(event){
|
||||
|
Loading…
Reference in New Issue
Block a user