RTCPeerConnection: currentRemoteDescription 屬性
RTCPeerConnection 介面的只讀屬性 currentRemoteDescription 返回一個 RTCSessionDescription 物件,該物件描述了自上一次 RTCPeerConnection 完成協商並連線到遠端對等端以來,最近一次成功協商的連線的遠端端。它還包含自描述首次例項化(作為 offer 或 answer)以來可能已被 ICE 代理生成的任何 ICE 候選者列表。
要更改 currentRemoteDescription,請呼叫 RTCPeerConnection.setRemoteDescription(),它會觸發一系列事件,從而導致此值被設定。有關確切發生的情況以及為什麼更改不一定即時生效的更多詳細資訊,請參閱 WebRTC 連線頁面中的 待定和當前描述。
注意:與 RTCPeerConnection.remoteDescription 不同,此值代表連線本地端的實際當前狀態;remoteDescription 可能指定連線當前正在切換到的描述。
值
連線遠端端的當前描述,如果已設定。如果未成功設定,則此值為 null。
示例
此示例檢查 currentRemoteDescription 並顯示一個包含 RTCSessionDescription 物件的 type 和 sdp 欄位的警告。
js
const pc = new RTCPeerConnection();
// …
const sd = pc.currentRemoteDescription;
if (sd) {
alert(`Local session: type='${sd.type}'; sdp description='${sd.sdp}'`);
} else {
alert("No local session yet.");
}
規範
| 規範 |
|---|
| WebRTC:瀏覽器中的即時通訊 # dom-peerconnection-currentremotedesc |
瀏覽器相容性
載入中…