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 |
浏览器兼容性
加载中…