You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 satır
1.9KB

  1. <head>
  2. <title>Demo static index</title>
  3. <link rel="stylesheet" type="text/css" href="css/index.css">
  4. </head>
  5. <body>
  6. <h1> Static Html Site </h1>
  7. <hr>
  8. <div class="center">
  9. <p >
  10. This is a static website located on /
  11. </p>
  12. <ol>
  13. <li>
  14. <a href="css/index.css"> css/index.css </a>
  15. </li>
  16. <li>
  17. static url <a href="spa1/"> /spa1 </a> &#x2192; "./html/test/"
  18. </li>
  19. <li>
  20. static url <a href="spa2/">/spa2 </a> &#x2192; "./html/test/"
  21. </li>
  22. <li>
  23. static url <a href="test/">/test </a> &#x2192; "./html/test/"
  24. </li>
  25. <script>
  26. let socket = new WebSocket("wss://svr2021.lawipac.com:8080/api/v1/ws");
  27. console.log("Attempting Connection...");
  28. socket.onopen = () => {
  29. console.log("Successfully Connected");
  30. socket.send("Hi From the Client!");
  31. socket.send("send dummy string for 500 times"); //this is a special command server will respond;
  32. };
  33. socket.onclose = event => {
  34. console.log("Socket Closed Connection: ", event);
  35. socket.send("Client Closed!")
  36. };
  37. socket.onerror = error => {
  38. console.log("Socket Error: ", error);
  39. };
  40. socket.onmessage = e => {
  41. if(typeof e.data != "string" ) {
  42. console.log("invalid data received ", e)
  43. }else{
  44. let server_message = e.data;
  45. console.log("server said: ", server_message)
  46. document.getElementById("socketOutPut").innerHTML= server_message;
  47. }
  48. }
  49. </script>
  50. </ol>
  51. <p id="socketOutPut"></p>
  52. </div>
  53. <!--<script type="text/javascript">-->
  54. <!-- setTimeout(function(){-->
  55. <!-- location.reload();-->
  56. <!-- },1000)-->
  57. <!--</script>-->
  58. </body>