跳转到内容
Tauri

@tauri-apps/plugin-websocket

默认

构造函数

new default()
new default(id, listeners): default
参数
参数类型
id数字
监听器(arg) => void[]
返回值

默认

来源: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/websocket/guest-js/index.ts#L37

属性

属性类型定义于
id数字来源: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/websocket/guest-js/index.ts#L34

方法

addListener()
addListener(cb): void
参数
参数类型
cb(arg) => void
返回值

void

来源: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/websocket/guest-js/index.ts#L66

disconnect()
disconnect(): Promise<void>
返回值

Promise<void>

来源: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/websocket/guest-js/index.ts#L89

send()
send(message): Promise<void>
参数
参数类型
messagestring | number[] | Message
返回值

Promise<void>

来源: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/websocket/guest-js/index.ts#L70

connect()
static connect(url, config?): Promise<default>
参数
参数类型
url字符串
config?ConnectionConfig
返回值

Promise<default>

来源: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/websocket/guest-js/index.ts#L42

接口

CloseFrame

属性

属性类型定义于
code数字来源: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/websocket/guest-js/index.ts#L22
reason字符串来源: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/websocket/guest-js/index.ts#L23

ConnectionConfig

属性

属性类型定义于
acceptUnmaskedFrames?布尔值来源: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/websocket/guest-js/index.ts#L12
headers?HeadersInit来源: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/websocket/guest-js/index.ts#L13
maxFrameSize?数字来源: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/websocket/guest-js/index.ts#L11
maxMessageSize?数字来源: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/websocket/guest-js/index.ts#L10
maxWriteBufferSize?数字来源: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/websocket/guest-js/index.ts#L9
writeBufferSize?数字来源: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/websocket/guest-js/index.ts#L8

MessageKind

类型参数

类型参数
T
D

属性

属性类型定义于
dataD来源: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/websocket/guest-js/index.ts#L18
typeT来源: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/websocket/guest-js/index.ts#L17

类型别名

消息

type Message:
| MessageKind<"Text", string>
| MessageKind<"Binary", number[]>
| MessageKind<"Ping", number[]>
| MessageKind<"Pong", number[]>
| MessageKind<"Close", CloseFrame | null>;

来源: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/websocket/guest-js/index.ts#L26


© 2025 Tauri 贡献者. CC-BY / MIT