RTCPeerConnection: sctp 属性

Baseline 2023
新推出

自 ⁨2023 年 5 月⁩起,此功能可在最新的设备和浏览器版本上使用。此功能可能无法在旧版设备或浏览器上使用。

RTCPeerConnection 接口中只读的 sctp 属性返回一个 RTCSctpTransport 对象,该对象描述了用于发送和接收 SCTP 数据的 SCTP 传输。如果尚未协商 SCTP,则此值为 null

SCTP 传输用于在对等连接上传输和接收所有 RTCDataChannel 的数据。

一个 RTCSctpTransport 对象,它描述了 RTCPeerConnection 用于在数据通道上传输和接收数据的 SCTP 传输,或者在 SCTP 协商尚未发生时返回 null

示例

js
const peerConnection = new RTCPeerConnection();

const channel = peerConnection.createDataChannel("Mydata");
channel.onopen = (event) => {
  channel.send("sending a message");
};
channel.onmessage = (event) => {
  console.log(event.data);
};

// Determine the largest message size that can be sent

const sctp = peerConnection.sctp;
const maxMessageSize = sctp.maxMessageSize;

规范

规范
WebRTC:浏览器中的实时通信
# dom-rtcpeerconnection-sctp

浏览器兼容性

另见