RTCDtlsTransportStateChangedEvent event
[Some information relates to pre-released product which may be substantially modified before it's commercially released. Microsoft makes no warranties, express or implied, with respect to the information provided here.]
This event fires when the RTCDtlsTransport
changes state.
Syntax
Event Property | object.RTCDtlsTransportStateChangedEvent = handler; |
Event information
Synchronous | No |
Bubbles | No |
Cancelable | No |
Event handler parameters
state
Type: RTCDtlsTransportStateThe state attribute is the new
RTCDtlsTransportState
that caused the event. (readonly) (nullable)
Standards information
Object RTC (ORTC) API for WebRTC
dictionary RTCDtlsTransportStateChangedEventInit : EventInit { RTCDtlsTransportState? state; };
[Constructor(DOMString type, RTCDtlsTransportStateChangedEventInit eventInitDict)] interface RTCDtlsTransportStateChangedEvent : Event { readonly attribute RTCDtlsTransportState state; };
Remarks
The dtlsstatechange
event of the RTCDtlsTransport
object uses the RTCDtlsTransportStateChangedEvent
interface.
Firing an RTCDtlsTransportStateChangedEvent
event named e with an RTCDtlsTransportState
state means that an event with the name e, which does not bubble (except where otherwise stated) and is not cancelable (except where otherwise stated), and which uses the RTCDtlsTransportStateChangedEvent
interface with the state attribute set to the new RTCDtlsTransportState
, must be created and dispatched at the given target.
Examples
// This is an example of how to offer ICE and DTLS parameters and
// ICE candidates and get back ICE and DTLS parameters and ICE candidates,
// and start both ICE and DTLS, when RTP and RTCP are multiplexed.
// Assume that we have a way to signal (mySignaller).
// Include some helper functions
import "helper.js";
function initiate(mySignaller) {
// Prepare the ICE gatherer
var gatherOptions = new RTCIceGatherOptions();
gatherOptions.gatherPolicy = RTCIceGatherPolicy.all;
gatherOptions.iceservers = [ { urls: "stun:stun1.example.net" } ,
{ urls:"turn:turn.example.org", username: "user", credential:"myPassword"} ];
var iceGatherer = new RTCIceGatherer(gatherOptions);
iceGatherer.onlocalcandidate = function(event) {
mySignaller.mySendLocalCandidate(event.candidate);
};
// Create ICE and DTLS transports
var ice = new RTCIceTransport();
var dtls = new RTCDtlsTransport(ice);
// Prepare to handle remote ICE candidates
mySignaller.onRemoteCandidate = function(candidate){
ice.addRemoteCandidate(candidate);
}
// ... create RtpSender/RtpReceiver objects as illustrated in Section 7.5 Example 9.
mySignaller.mySendInitiate({
"ice": iceGatherer.getLocalParameters(),
"dtls": dtls.getLocalParameters(),
// ... include RTP info from other example
}, function(remote) {
// Start the ICE transport
ice.start(iceGatherer, remote.ice, RTCIceRole.controlling);
dtls.start(remote.dtls);
// ... configure RtpSender/RtpReceiver objects as illustrated in Section 7.5 Example 9.
});
}
// This is an example of how to answer with ICE and DTLS
// and DTLS parameters and ICE candidates and start both ICE and DTLS,
// assuming that RTP and RTCP are multiplexed.
// Include some helper functions
import "helper.js";
// Assume that remote info is signalled to us.
function accept(mySignaller, remote) {
var gatherOptions = new RTCIceGatherOptions();
gatherOptions.gatherPolicy = RTCIceGatherPolicy.all;
gatherOptions.iceservers = [ { urls: "stun:stun1.example.net" } ,
{ urls:"turn:turn.example.org", username: "user", credential:"myPassword"} ] ;
var iceGatherer = new RTCIceGatherer(gatherOptions);
iceGatherer.onlocalcandidate = function(event) {
mySignaller.mySendLocalCandidate(event.candidate);
};
// Create ICE and DTLS transports
var ice = new RTCIceTransport();
var dtls = new RTCDtlsTransport(ice);
// Prepare to handle remote ICE candidates
mySignaller.onRemoteCandidate = function(candidate){
ice.addRemoteCandidate(candidate);
}
// ... create RtpSender/RtpReceiver objects as illustrated in Section 7.5 Example 9.
mySignaller.mySendAccept({
"ice": iceGatherer.getLocalParameters(),
"dtls": dtls.getLocalParameters()
// ... marshall RtpSender/RtpReceiver capabilities as illustrated in Section 7.5 Example 9.
});
// Start the ICE transport with an implicit gather policy of "all"
ice.start(iceGatherer, remote.ice, RTCIceRole.controlled);
// Start the DTLS transport
dtls.start(remote.dtls);
// ... configure RtpSender/RtpReceiver objects as illustrated in Section 7.5 Example 9.
}