控制台简易测试websocket

   var ws = new WebSocket('ws://localhost:8080');
   ws.onopen = function() {
       ws.send('Hello, server!');
   };
   ws.onmessage = function(event) {
       console.log('Received: ' + event.data);
   };

你可能感兴趣的:(websocket,前端,javascript)