WebTransport API
The close() method of the WebTransport interface closes an ongoing WebTransport session.
Syntax
close(info)
Parameters
info- : An object containing the following properties:
closeCode- : A number representing the error code for the error.
reason- : A string representing the reason for closing the
WebTransport.
- : A string representing the reason for closing the
- : An object containing the following properties:
Return value
undefined.
Exceptions
- WebTransportError
- : Thrown if
close()is invoked while the WebTransport is in the process of connecting.
- : Thrown if
Examples
const url = "https://example.com:4999/wt";
// Initialize transport connection
const transport = new WebTransport(url);
// …
transport.close({
closeCode: 17,
reason: "CloseButtonPressed",
});
Specifications
Browser compatibility
See also
- Using WebTransport
- WebSockets API
- Streams API
- WebTransport over HTTP/3
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
