index.html 583 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>ws test</title>
  6. <script src="data.js"></script>
  7. </head>
  8. <body>
  9. <script>
  10. function on_ws_msg(bin){
  11. var j = BIN.hdr.b2j(bin);
  12. console.log(j);
  13. }
  14. function ws_hdr(){
  15. var proto = window.location.protocol,ws;
  16. if (proto == 'https:'){
  17. ws = 'wss://';
  18. }else{
  19. ws = 'ws://';
  20. }
  21. return ws;
  22. }
  23. var ws = new WS("ws://192.168.234.132/ws",on_ws_msg);
  24. </script>
  25. </body>
  26. </html>