From 7343241c3d703b18c16ca758f12ae082c0ff2bd2 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 6 Mar 2019 13:11:50 +0530 Subject: [PATCH] Add RTCPeerConnection::Close --- components/script/dom/rtcpeerconnection.rs | 25 +++++++++++++++++++ .../dom/webidls/RTCPeerConnection.webidl | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/components/script/dom/rtcpeerconnection.rs b/components/script/dom/rtcpeerconnection.rs index f9bb844d8fe..e4948e08d8e 100644 --- a/components/script/dom/rtcpeerconnection.rs +++ b/components/script/dom/rtcpeerconnection.rs @@ -586,6 +586,31 @@ impl RTCPeerConnectionMethods for RTCPeerConnection { fn SignalingState(&self) -> RTCSignalingState { self.signaling_state.get() } + + /// https://www.w3.org/TR/webrtc/#dom-rtcpeerconnection-close + fn Close(&self) { + // Step 1 + if self.closed.get() { + return; + } + // Step 2 + self.closed.set(true); + + // Step 4 + self.signaling_state.set(RTCSignalingState::Closed); + + // Step 5 handled by backend + self.controller.borrow_mut().as_ref().unwrap().quit(); + + // Step 6-10 + // (no current support for data channels, transports, etc) + + // Step 11 + self.ice_connection_state.set(RTCIceConnectionState::Closed); + + // Step 11 + // (no current support for connection state) + } } impl From for RTCSessionDescriptionInit { diff --git a/components/script/dom/webidls/RTCPeerConnection.webidl b/components/script/dom/webidls/RTCPeerConnection.webidl index 60447917b3e..0f00f3b5b95 100644 --- a/components/script/dom/webidls/RTCPeerConnection.webidl +++ b/components/script/dom/webidls/RTCPeerConnection.webidl @@ -26,7 +26,7 @@ interface RTCPeerConnection : EventTarget { // static sequence getDefaultIceServers(); // RTCConfiguration getConfiguration(); // void setConfiguration(RTCConfiguration configuration); - // void close(); + void close(); attribute EventHandler onnegotiationneeded; attribute EventHandler onicecandidate; // attribute EventHandler onicecandidateerror;