Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width">
  6. <title>JS Bin</title>
  7. </head>
  8. <body>
  9.  
  10. <script id="jsbin-javascript">
  11. var ws = new WebSocket("wss://yejiaxi.cn:8080");
  12.  
  13. ws.onopen = function(evt) {
  14. console.log("Connection open ...");
  15. ws.send("Hello WebSockets!");
  16. };
  17.  
  18. ws.onmessage = function(evt) {
  19. console.log( "Received Message: " + evt.data);
  20. ws.close();
  21. };
  22.  
  23. ws.onclose = function(evt) {
  24. console.log("Connection closed.");
  25. };
  26. </script>
  27.  
  28.  
  29.  
  30. <script id="jsbin-source-javascript" type="text/javascript">var ws = new WebSocket("wss://yejiaxi.cn:8080");
  31.  
  32. ws.onopen = function(evt) {
  33. console.log("Connection open ...");
  34. ws.send("Hello WebSockets!");
  35. };
  36.  
  37. ws.onmessage = function(evt) {
  38. console.log( "Received Message: " + evt.data);
  39. ws.close();
  40. };
  41.  
  42. ws.onclose = function(evt) {
  43. console.log("Connection closed.");
  44. };
  45.  
  46. </script></body>
  47. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement