}
type DataChannelContext struct {
+ // Can these be obtained by just calling the relevant methods on peerConnection?
Local, Remote webrtc.SessionDescription
OfferId string
LocalOffered bool
InfoHash [20]byte
+ // This is private as some methods might not be appropriate with data channel context.
+ peerConnection *wrappedPeerConnection
+}
+
+func (me *DataChannelContext) GetSelectedIceCandidatePair() (*webrtc.ICECandidatePair, error) {
+ return me.peerConnection.SCTP().Transport().ICETransport().GetSelectedCandidatePair()
}
type onDataChannelOpen func(_ datachannel.ReadWriteCloser, dcc DataChannelContext)
tc.stats.ConvertedInboundConns++
tc.mu.Unlock()
tc.OnConn(dc, DataChannelContext{
- Local: answer,
- Remote: offer,
- OfferId: offerId,
- LocalOffered: false,
- InfoHash: infoHash,
+ Local: answer,
+ Remote: offer,
+ OfferId: offerId,
+ LocalOffered: false,
+ InfoHash: infoHash,
+ peerConnection: peerConnection,
})
})
})
tc.stats.ConvertedOutboundConns++
tc.mu.Unlock()
tc.OnConn(dc, DataChannelContext{
- Local: offer.originalOffer,
- Remote: answer,
- OfferId: offerId,
- LocalOffered: true,
- InfoHash: offer.infoHash,
+ Local: offer.originalOffer,
+ Remote: answer,
+ OfferId: offerId,
+ LocalOffered: true,
+ InfoHash: offer.infoHash,
+ peerConnection: offer.peerConnection,
})
})
if err != nil {