WebSocket
WebSocket 类表示页面内的 WebSocket 连接。它提供了检查和操作正在发送和接收的数据的能力。
🌐 The WebSocket class represents WebSocket connections within a page. It provides the ability to inspect and manipulate the data being transmitted and received.
如果你想拦截或修改 WebSocket 帧,可以考虑使用 WebSocketRoute。
🌐 If you want to intercept or modify WebSocket frames, consider using WebSocketRoute.
方法
🌐 Methods
IsClosed
Added before v1.9表示 Web 套接字已关闭。
🌐 Indicates that the web socket has been closed.
用法
WebSocket.IsClosed
返回
Url
Added before v1.9包含 WebSocket 的 URL。
🌐 Contains the URL of the WebSocket.
用法
WebSocket.Url
返回
事件
🌐 Events
event Close
Added before v1.9当 websocket 关闭时触发。
🌐 Fired when the websocket closes.
用法
WebSocket.Close += async (_, webSocket) => {};
事件数据
event FrameReceived
Added in: v1.9当 websocket 收到帧时触发。
🌐 Fired when the websocket receives a frame.
用法
WebSocket.FrameReceived += async (_, webSocketFrame) => {};
事件数据
event FrameSent
Added in: v1.9当 websocket 发送帧时触发。
🌐 Fired when the websocket sends a frame.
用法
WebSocket.FrameSent += async (_, webSocketFrame) => {};
事件数据
event SocketError
Added in: v1.9当 websocket 出现错误时触发。
🌐 Fired when the websocket has an error.
用法
WebSocket.SocketError += async (_, value) => {};
事件数据