index.html 748 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. j.chall = 1;
  13. j.type = PKT_TYPE.PKT_TYPE_CH_ALL;
  14. console.log(j);
  15. var b = BIN.hdr.j2b(j);
  16. console.log(b);
  17. ws.send(b);
  18. }
  19. function ws_hdr(){
  20. var proto = window.location.protocol,ws;
  21. if (proto == 'https:'){
  22. ws = 'wss://';
  23. }else{
  24. ws = 'ws://';
  25. }
  26. return ws;
  27. }
  28. ws = new WS("ws://192.168.234.132/ws",on_ws_msg);
  29. </script>
  30. </body>
  31. </html>