bugfix
This commit is contained in:
parent
b6ca1750b2
commit
520e2ad10c
@ -335,12 +335,13 @@ bricks.RTCP2PConnect = class {
|
|||||||
this.opts.data_connect,
|
this.opts.data_connect,
|
||||||
'role=', role);
|
'role=', role);
|
||||||
if (role == 'requester'){
|
if (role == 'requester'){
|
||||||
var dc = pc.createDataChannel('chat');
|
this.peers[peer.id].dc = pc.createDataChannel('chat');
|
||||||
await this.dc_created(peer, dc);
|
var dc = this.peers[peer.id].dc;
|
||||||
|
await this.dc_created(peer, this.peers[peer.id].dc);
|
||||||
if(this.opts.on_pc_connected){
|
if(this.opts.on_pc_connected){
|
||||||
this.opts.on_pc_connected(peer);
|
this.opts.on_pc_connected(peer);
|
||||||
}
|
}
|
||||||
console.log('dc created', dc);
|
console.log('dc created', this.peers[peer.id].dc);
|
||||||
} else {
|
} else {
|
||||||
console.log('87y333333333333333333333333333333333354');
|
console.log('87y333333333333333333333333333333333354');
|
||||||
}
|
}
|
||||||
@ -349,33 +350,32 @@ bricks.RTCP2PConnect = class {
|
|||||||
|
|
||||||
async dc_accepted(peer, event){
|
async dc_accepted(peer, event){
|
||||||
console.log('accept datachannel ....');
|
console.log('accept datachannel ....');
|
||||||
dc = event.channel;
|
this.peers[peer.id].dc = event.channel;
|
||||||
await this.dc_created(peer, event);
|
await this.dc_created(peer, this.peers[peer.id].dc);
|
||||||
}
|
}
|
||||||
async dc_created(peer, dc){
|
async dc_created(peer, dc){
|
||||||
console.log('dc_created.....', dc);
|
console.log('dc_created.....', dc);
|
||||||
this.peers[peer.id].dc = dc;
|
|
||||||
dc.onmessage = this.datachannel_message.bind(this, peer);
|
dc.onmessage = this.datachannel_message.bind(this, peer);
|
||||||
dc.onopen = this.datachannel_open(this, peer);
|
dc.onopen = this.datachannel_open(this, peer);
|
||||||
dc.onclose = this.datachannel_close(this, peer);
|
dc.onclose = this.datachannel_close(this, peer);
|
||||||
}
|
}
|
||||||
|
|
||||||
async datachannel_message(peer, msg){
|
async datachannel_message(peer, msg){
|
||||||
console.log('datachannel_message():', peer. msg);
|
console.log('datachannel_message():', this, peer, msg);
|
||||||
var dc = this.peers[peer.id].dc;
|
var dc = this.peers[peer.id].dc;
|
||||||
if (this.opts.on_dc_messaage){
|
if (this.opts.on_dc_messaage){
|
||||||
await this.opts.on_dc_message(dc, msg);
|
await this.opts.on_dc_message(dc, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async datachannel_open(peer){
|
async datachannel_open(peer){
|
||||||
console.log('datachannel_open():', arguments, peer);
|
console.log('datachannel_open():', this, peer);
|
||||||
var dc = this.peers[peer.id].dc
|
var dc = this.peers[peer.id].dc
|
||||||
if (this.opts.on_dc_open){
|
if (this.opts.on_dc_open){
|
||||||
await this.opts.on_dc_open(dc);
|
await this.opts.on_dc_open(dc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async datachannel_close(peer){
|
async datachannel_close(peer){
|
||||||
console.log('datachannel_close():', peer);
|
console.log('datachannel_close():', this, peer);
|
||||||
var dc = this.peers[peer.id].dc
|
var dc = this.peers[peer.id].dc
|
||||||
if (this.opts.on_dc_close){
|
if (this.opts.on_dc_close){
|
||||||
await this.opts.on_dc_close(dc);
|
await this.opts.on_dc_close(dc);
|
||||||
|
Loading…
Reference in New Issue
Block a user