      connection.onclose = function (reason, details) {

         console.log("Connection lost: " + reason);

      }

      // now actually open the connection
      //
      connection.open();

      var thresholdValue = document.getElementById("thresholdValue");
      document.getElementById("setThreshold").addEventListener("click", function() {
         session.call("io.crossbar.examples.yun.ambientlight.set_threshold", [parseInt(thresholdValue.value)]);
      })
   </script>
</body>
</html>