index.html 949 B

123456789101112131415161718192021222324252627282930313233343536
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>GildasCh</title>
  5. <meta charset='utf-8' />
  6. <style>
  7. body {
  8. background-color:#263238;
  9. }
  10. img {
  11. position: absolute;
  12. top: 50%;
  13. left: 50%;
  14. width: 425px;
  15. height: 224px;
  16. margin-left: -212px; /* Half the width */
  17. margin-top: -112px; /* Half the height */
  18. }
  19. </style>
  20. </head>
  21. <body>
  22. <img id='image' style='-webkit-user-select: none' src='http://localhost:8080/a.jpg' />
  23. <script>
  24. var connection = new WebSocket('ws://localhost:8080/ws', []);
  25. var counter = 0;
  26. connection.onmessage = function (e) {
  27. document.getElementById('image').src='http://localhost:8080/a.jpg?'+counter;
  28. console.log('Server: ' + e.data);
  29. counter++;
  30. };
  31. </script>
  32. </body>
  33. </html>