datachannel: handle data before final ICE pair selection, fix agent deadlock

This commit is contained in:
backkem
2018-08-13 23:15:09 +02:00
committed by Sean DuBois
parent 168bf78504
commit aa22a92b18
4 changed files with 101 additions and 41 deletions

View File

@@ -37,17 +37,25 @@ func main() {
panic(err)
}
// Set the handler for ICE connection state
// This will notify you when the peer has connected/disconnected
peerConnection.OnICEConnectionStateChange = func(connectionState ice.ConnectionState) {
fmt.Printf("Connection State has changed %s \n", connectionState.String())
}
d, err := peerConnection.CreateDataChannel("data", nil)
if err != nil {
panic(err)
}
// Set the handler for ICE connection state
// This will notify you when the peer has connected/disconnected
peerConnection.OnICEConnectionStateChange = func(connectionState ice.ConnectionState) {
// TODO: find the correct place of this
fmt.Printf("Connection State has changed %s \n", connectionState.String())
if connectionState == ice.ConnectionStateConnected {
fmt.Println("sending openchannel")
err := d.SendOpenChannelMessage()
if err != nil {
fmt.Println("faild to send openchannel", err)
}
}
}
fmt.Printf("New DataChannel %s %d\n", d.Label, d.ID)
d.Lock()