techproof.html 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <title>Technical proof for server function</title>
  5. <script src="http://localhost:8123/socket.io/socket.io.js"></script>
  6. </head>
  7. <body>
  8. <p>This implements a subset of the communication which our example scene does. This is made to prove, that the server actually works. We created this as a debug tool to ensure that the server does what we expect, as many requests ahve been opened which were traced down to server-side issues.</p>
  9. <hr>
  10. <pre id="output"></pre>
  11. <script>
  12. const sio = io("ws://localhost:8123", { transports: ["websocket"] }); //we are disabling longpolling for the test as native client does only support websocket
  13. const o = document.getElementById('output');
  14. function log(line) {
  15. o.innerHTML += line + "\n";
  16. console.log(line);
  17. }
  18. window.onload = function () {
  19. console.log("Starting test...");
  20. sio.on('connect', () => {
  21. log('LOCAL: Hey, we are connected!');
  22. sio.emit('KnockKnock');
  23. });
  24. sio.on('WhosThere', () => {
  25. log('RECEIVED a WhosThere event without payload data just as expected.');
  26. sio.emit('ItsMe', {
  27. version: 'FakeVersion'
  28. });
  29. });
  30. sio.on('Welcome', (payload) => {
  31. log('SERVER: ' + payload);
  32. });
  33. sio.on('TechData', (srv) => {
  34. log("Received the POD name from the server. Upadting UI. Oh! It's " + srv.timestamp + " by the way."); //we do not acually update ui in the test app
  35. });
  36. sio.on('disconnect', () => {
  37. log('Disconnected from server.'); //we do not acually update ui in the test app
  38. sio.close();
  39. });
  40. }
  41. </script>
  42. </bod>