originalOffer webrtc.SessionDescription
peerConnection wrappedPeerConnection
dataChannel *webrtc.DataChannel
- // Whether we've received an answer for this offer, and closing its PeerConnection has been
- // handed off.
- answered bool
}
type DataChannelContext struct {
func (tc *TrackerClient) closeUnusedOffers() {
for _, offer := range tc.outboundOffers {
- if offer.answered {
- continue
- }
offer.peerConnection.Close()
}
tc.outboundOffers = nil
func (t *outboundOffer) setAnswer(answer webrtc.SessionDescription, onOpen func(datachannel.ReadWriteCloser)) error {
setDataChannelOnOpen(t.dataChannel, t.peerConnection, onOpen)
err := t.peerConnection.SetRemoteDescription(answer)
- if err == nil {
- // TODO: Maybe grab this inside the onOpen callback and mark the offer used there.
- t.answered = true
- }
return err
}