RTCPeerConnection.peerIdentity

翻译不完整。 请帮助我们翻译这篇文章!

只读属性 RTCPeerConnection  peerIdentity ,返回Promise 对象,成功时返回 RTCIdentityAssertion ,该结构 DOMString 标识了远端的ID。这个身份标识在连接过程中将不会改变(直到连接结束).

语法

 var identity = rtcPeerConnection.peerIdentity;

Value

A JavaScript Promise which resolves to an RTCIdentityAssertion that describes the remote peer's identity.

当验证远程的身份ID出错时,  promise 将返回拒绝. 如果目标节点身份不存在, peerIdentity 将被设为 一个promise对象,并重启验证过程(一个断言), 直到成功或者不再想继续。

注意: setRemoteDescription() 返回的promise 将不会成功返回,除非目标节点身份信息可用。 如不可用,则setRemoteDescription() 将被拒绝. 若无目标节点ID, 就不不需要等setRemoteDescription() 这个返回验证成功了.

举个栗子

In this example, a function, getIdentityAssertion(), is created which asynchronously waits for the peer's identity to be verified, then returns the identity to the caller. If an error occurs and the promise is rejected, this logs the error to the console and returns null to the caller.

let pc = new RTCPeerConnection();

/* ... */

async function getIdentityAssertion(pc) {
  try {
    const identity = await pc.peerIdentity;
    return identity;
  } catch(err) {
    console.log("Error identifying remote peer: ", err);
    return null;
  }
}

Specifications

Specification Status Comment
Identity for WebRTC Candidate Recommendation Initial specification.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
peerIdentityChrome No support NoEdge Full support YesFirefox Full support 22IE No support NoOpera Full support 43
Notes
Full support 43
Notes
Notes Promise-based version.
No support 37 — 43
Safari ? WebView Android No support NoChrome Android No support NoFirefox Android Full support 44Opera Android Full support 43
Notes
Full support 43
Notes
Notes Promise-based version.
No support 37 — 43
Safari iOS ? Samsung Internet Android Full support 6.0

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
See implementation notes.
See implementation notes.

See also