Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
</body>
</html>
 
 
var ws = new WebSocket("wss://echo.websocket.org");
console.log(ws.readyState);
ws.onopen = function()
{
  console.log("已连接socket!");
  console.log(ws.readyState);
  ws.send("这是发送的消息...");
}
ws.onmessage = function(evt)
{
  console.log("这是接收的信息:" + evt.data);
  ws.close();//关闭链接
  console.log(ws.readyState);
}
ws.onclose = function(evt)
{
  console.log("连接已关闭!");
  console.log(ws.readyState);
}
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers