# HTML5 WebSocket ###### tags: `websocket` ## 建立 ``` var Socket = new WebSocket(url, [protocol] ); ``` ## 屬性 | Attritube | 0 | 1 | 2 | 3 | | -------- | -------- | -------- | -------- | -------- | | Socket.readyState | 尚未建立連接| 已建立可通信| 正在進行關閉| 已關閉| ## 事件 | 事件 | 處理程序 | 描述 | | -------- | -------- | -------- | | open | Socket.onopen | 连接建立时触发 | | message | Socket.onmessage | 客户端接收服务端数据时触发 | | error | Socket.onerror | 通信发生错误时触发 | | close | Socket.onclose | 连接关闭时触发 | ## 方法 | 方法 | 描述 | | -------- | -------- | | Socket.send() | 使用连接发送数据 | | Socket.close() | 关闭连接 |
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up