RTCPeerConnection.getConfiguration() - Web APIs 编辑

Experimental

This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The 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(), or if 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.

Syntax

var configuration = RTCPeerConnection.getConfiguration();

Parameters

This method takes no input parameters.

Return value

An RTCConfiguration object describing the RTCPeerConnection's current configuration.

Example

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.

Specifications

SpecificationStatusComment
WebRTC 1.0: Real-time Communication Between Browsers
The definition of 'getConfiguration()' in that specification.
Candidate RecommendationInitial definition.

Browser compatibility

BCD tables only load in the browser

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:82 次

字数:4754

最后编辑:6 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文