这是 实验性技术
检查 浏览器兼容性表格 要小心谨慎在生产中使用这之前。

RTCPeerConnection.getConfiguration() method returns an RTCConfiguration object which indicates the current configuration of the RTCPeerConnection on which the method is called.

The returned configuration is the last configuration applied via setConfiguration() ,或者若 setConfiguration() hasn't been called, the configuration the RTCPeerConnection was constructed with. The configuration includes a list of the ICE servers used by the connection, information about transport policies, and identity information.

句法

var configuration = RTCPeerConnection.getConfiguration();
					

参数

This method takes no input parameters.

返回值

RTCConfiguration object describing the RTCPeerConnection 's current configuration.

范例

This example adds a new certificate to an active connection if it doesn't already have one in use.

let configuration = myPeerConnection.getConfiguration();
if ((configuration.certificates != undefined) && (!configuration.certificates.length)) {
   RTCPeerConnection.generateCertificate({
      name: 'RSASSA-PKCS1-v1_5',
      hash: 'SHA-256',
      modulusLength: 2048,
      publicExponent: new Uint8Array([1, 0, 1])
  }).then(function(cert) {
    configuration.certificates = [cert];
    myPeerConnection.setConfiguration(configuration);
  });
}
					

This example fetches the current configuration of the RTCPeerConnection , then looks to see if it has any certificates set by examining whether or not (a) the configuration has a value for certificates , and (b) whether its length is zero.

If it's determined that there are no certificates in place, RTCPeerConnection.generateCertificate() is called to create a new certificate; we provide a fulfillment handler which adds a new array containing the one newly-created certificate to the current configuration and passes it to setConfiguration() to add the certificate to the connection.

规范

规范 状态 注释
WebRTC 1.0: Real-time Communication Between Browsers
The definition of 'getConfiguration()' in that specification.
候选推荐 初始定义。

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
getConfiguration Chrome 70 Edge 15 Firefox 22 IE 不支持 No Opera 43 注意事项
43 注意事项
Promise-based version.
37 — 43
Safari 11 WebView Android 70 Chrome Android 70 Firefox Android 44 Opera Android 43 注意事项
43 注意事项
Promise-based version.
37 — 43
Safari iOS Yes Samsung Internet Android 6.0

图例

完整支持

完整支持

不支持

不支持

见实现注意事项。

另请参阅

元数据

  • 最后修改: