Skip to content

Instantly share code, notes, and snippets.

@snay2
Created July 20, 2011 17:23
Show Gist options
  • Save snay2/1095411 to your computer and use it in GitHub Desktop.
Save snay2/1095411 to your computer and use it in GitHub Desktop.
Using localtunnel with Kynetx
# The webhook that should be notified when the tunnel is created. In this case, a
# webhook handled by a Kynetx ruleset.
app_url = "http://webhooks.kynetxapps.net/h/a000x000.dev/set_tunnel"
# Create and open the tunnel
tunnel = LocalTunnel::Tunnel.new(4567, key, app_url)
tunnel.register_tunnel()
tunnel.start_tunnel()
rule set_tunnel {
select when webhook set_tunnel
pre {
tunnel = "http://" + event:param("tunnel") + "/";
}
webhook:text(tunnel);
fired {
set app:tunnel tunnel;
}
}
// Get/set the light level
set_light_level = defaction(level) {
http:get(app:tunnel + "light_level/#{level}");
};
get_light_level = function() {
http:get(app:tunnel + "light_level").pick("content").decode().pick("light_level");
};
// Get/set the media state
set_media_state = defaction(state) {
http:get(app:tunnel + "media_state/#{state}");
};
get_media_state = function() {
http:get(app:tunnel + "media_state").pick("content").decode().pick("media_state");
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment