Websocket

WebSocket 是一种在单个 TCP 连接上进行全双工通讯的协议。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
var ws = new WebSocket(url, [protocol] );

var ws = new WebSocket("ws://example.com", [protocol] );

ws.onopen = function (){
ws.send('message');
}

ws.onmessage = function (evt){
var received = evt.data;
}

ws.onclose = function (){

}
0%