<head>
<script src="/js/socket.io.js"></script>
</head>
<body>
  <p id="debug"></p>
  <script>
    const socket = io('http://172.20.10.14:3000')

    function onClick() {
      // feature detect
      if (typeof DeviceOrientationEvent.requestPermission === 'function') {
        DeviceOrientationEvent.requestPermission()
        .then(permissionState => {
          if (permissionState === 'granted') {
            window.addEventListener('deviceorientation', handleOrientation, true)
          }
        })
        .catch(console.error);
      } else {
        // handle regular non iOS 13+ devices
      }
    }
    document.body.onclick = onClick

    function handleOrientation (event) {
      const alpha = event.alpha;
      const beta = event.beta;
      const gamma = event.gamma;

      socket.emit('gyro', { alpha, beta, gamma })

      debug.innerHTML = `
        alpha (z, -360 to 360): ${alpha}<br>
        beta (x, -180 to 180): ${beta}<br>
        gamma (y, -90 to 90): ${gamma}
      `
    }
  </script>
</body>
<head>
<script src="/js/socket.io.js"></script>
</head>
<body>
  <p id="debug"></p>
  <script>
    const socket = io('https://172.20.10.14:3000')

    function onClick() {
      // feature detect
      if (typeof DeviceOrientationEvent.requestPermission === 'function') {
        DeviceOrientationEvent.requestPermission()
        .then(permissionState => {
          if (permissionState === 'granted') {
            window.addEventListener('deviceorientation', handleOrientation, true)
          }
        })
        .catch(console.error);
      } else {
        // handle regular non iOS 13+ devices
      }
    }
    document.body.onclick = onClick

    function handleOrientation (event) {
      const alpha = event.alpha;
      const beta = event.beta;
      const gamma = event.gamma;

      socket.emit('gyro', { alpha, beta, gamma })

      debug.innerHTML = `
        alpha (z, -360 to 360): ${alpha}<br>
        beta (x, -180 to 180): ${beta}<br>
        gamma (y, -90 to 90): ${gamma}
      `
    }
  </script>
</body>
Connect to socket.io through https
Connect to socket.io through https
