<script> var ws = new WebSocket("ws://114.215.103.25:9501"); ws.onopen = function(){ console.log("握手成功"); }; ws.onmessage = function(messageEvent){ console.debug(messageEvent.data); }; ws.onerror = function(errorEvent){ console.log(errorEvent); }; ws.onclose = function(closeEvent){ console.log(closeEvent); }; </script>
原文地址:http://kidly.blog.51cto.com/7565910/1658462