WebTransport:reliability 屬性
注意:此功能在 Web Workers 中可用。
reliability 是 WebTransport 介面的一個只讀屬性,它指示連線是僅支援可靠傳輸,還是也支援不可靠傳輸(例如 UDP)。
值
一個字串,其值可能為以下之一:
pending-
連線尚未建立。可靠性尚不確定。
reliable-only-
連線僅支援可靠傳輸。
supports-unreliable-
連線同時支援不可靠傳輸和可靠傳輸。
示例
js
const url = "https://example.com:4999/wt";
async function initTransport(url) {
// Initialize transport connection
const transport = new WebTransport(url);
// Once ready fulfils the connection can be used
// Prior to this the reliability is "pending"
await transport.ready;
if (transport.reliability === "reliable-only") {
// Use connection only with reliable transports
} else {
// Use connection with either reliable or unreliable transports.
}
// …
}
規範
| 規範 |
|---|
| WebTransport # dom-webtransport-reliability |
瀏覽器相容性
載入中…