Update examples

TestNonFatalRead now has an timeout.
Examples now use Mime types, instead of raw strings.

Fixes #839
This commit is contained in:
Antoine Baché
2021-06-28 22:39:11 +02:00
committed by Sean DuBois
parent 8a0df90831
commit 7e049ec5ec
21 changed files with 436 additions and 63 deletions

View File

@@ -3,7 +3,9 @@
package main
import (
"errors"
"fmt"
"io"
"net"
"github.com/pion/webrtc/v3"
@@ -59,6 +61,12 @@ func main() {
// This will notify you when the peer has connected/disconnected
peerConnection.OnICEConnectionStateChange(func(connectionState webrtc.ICEConnectionState) {
fmt.Printf("Connection State has changed %s \n", connectionState.String())
if connectionState == webrtc.ICEConnectionStateFailed {
if closeErr := peerConnection.Close(); closeErr != nil {
panic(closeErr)
}
}
})
// Wait for the offer to be pasted
@@ -101,6 +109,11 @@ func main() {
}
if _, err = videoTrack.Write(inboundRTPPacket[:n]); err != nil {
if errors.Is(err, io.ErrClosedPipe) {
// The peerConnection has been closed.
return
}
panic(err)
}
}