标签:span new web 链接 pre api 错误 echo cti
1 var ws = new WebSocket(‘ws://echo.websocket.org/‘); 2 3 ws.onopen = function() 4 { 5 ws.send(‘ok‘); 6 }; 7 8 ws.onmessage = function(evt) 9 10 { 11 12 console.log(evt.data) 13 14 }; 15 16 ws.onclose = function(evt) 17 18 { 19 20 console.log(断开); 21 22 }; 23 24 ws.onerror = function(evt) 25 26 { 27 28 console.log(‘错误‘); 29 30 };
WebSocket是html5的api,别名叫长链接。
标签:span new web 链接 pre api 错误 echo cti
原文地址:http://www.cnblogs.com/webSong/p/7091097.html