WebTransportDatagramDuplexStream: outgoingMaxAge 屬性

可用性有限

此特性不是基線特性,因為它在一些最廣泛使用的瀏覽器中不起作用。

安全上下文: 此功能僅在安全上下文(HTTPS)中可用,且支援此功能的瀏覽器數量有限。

注意:此功能在 Web Workers 中可用。

WebTransportDatagramDuplexStream 介面的 outgoingMaxAge 屬性用於獲取或設定傳出資料報的最大存活時間(以毫秒為單位)。

一個數字,如果未設定最大存活時間,則為 null

示例

js
const url = "https://example.com:4999/wt";

async function initTransport(url) {
  // Initialize transport connection
  const transport = new WebTransport(url);

  // The connection can be used once ready fulfills
  await transport.ready;

  const datagrams = transport.datagrams;

  // set outgoingMaxAge
  datagrams.outgoingMaxAge = 2000;

  // get outgoingMaxAge
  console.log(datagrams.outgoingMaxAge);
}

規範

規範
WebTransport
# dom-webtransportdatagramduplexstream-outgoingmaxage

瀏覽器相容性

另見