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

瀏覽器相容性

另見