sctp
sctp copied to clipboard
Fix OpenStream return a closed stream
Description
i want to reuse StreamIdentifier after the parent dc closed, but the current code will return a broken datachannel with a closed stream
package main
import (
"fmt"
"time"
"github.com/lainio/err2/try"
"github.com/pion/webrtc/v3"
)
func main2() {
var api *webrtc.API
var pc *webrtc.PeerConnection
defer pc.Close()
var id uint16 = 0
for {
go func() {
// id++
params := &webrtc.DataChannelParameters{
ID: &id,
}
dc := try.To1(
api.NewDataChannel(pc.SCTP(), params))
defer dc.Close()
conn := try.To1(
dc.Detach())
fmt.Fprintln(conn, "woooooooooo")
for {
n := dc.BufferedAmount()
if n == 0 {
break
}
}
}()
time.Sleep(3 * time.Second)
}
}
Reference issue
Fixes #...