mirror of
https://github.com/pion/webrtc.git
synced 2025-10-06 07:37:10 +08:00
datachannel: handle data before final ICE pair selection, fix agent deadlock
This commit is contained in:
@@ -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()
|
||||
|
Reference in New Issue
Block a user