session.destroy([error[, options]])


  • error <any>
  • options <Object>
    • code <bigint> | <number> 发送给对端的 CONNECTION_CLOSE 帧中要包含的错误代码。默认值: 0
    • type <string> 要么 'transport',要么 'application'默认值: 'transport'
    • reason <string> 包含在 CONNECTION_CLOSE 帧中的可选可读原因字符串。

立即销毁会话。所有流将被销毁,会话将被关闭。如果提供了 error 且设置了 session.onerror,在销毁之前会调用 onerror 回调。session.closed promise 将以错误拒绝。如果提供了 options,发送给对等方的 CONNECTION_CLOSE 帧将包含指定的错误代码、类型和原因。

🌐 Immediately destroy the session. All streams will be destroyed and the session will be closed. If error is provided and session.onerror is set, the onerror callback is invoked before destruction. The session.closed promise will reject with the error. If options is provided, the CONNECTION_CLOSE frame sent to the peer will include the specified error code, type, and reason.