mirror of
https://github.com/pion/webrtc.git
synced 2025-10-05 15:16:52 +08:00
Add ICE connection state change notification and timeouts
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/pions/webrtc"
|
||||
"github.com/pions/webrtc/pkg/ice"
|
||||
"github.com/pions/webrtc/pkg/rtp"
|
||||
)
|
||||
|
||||
@@ -49,6 +50,12 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
// 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())
|
||||
}
|
||||
|
||||
// Set the remote SessionDescription
|
||||
if err := peerConnection.SetRemoteDescription(string(sd)); err != nil {
|
||||
panic(err)
|
||||
|
Reference in New Issue
Block a user