Created
          July 20, 2011 17:23 
        
      - 
      
- 
        Save snay2/1095411 to your computer and use it in GitHub Desktop. 
    Using localtunnel with Kynetx
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # 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() | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | rule set_tunnel { | |
| select when webhook set_tunnel | |
| pre { | |
| tunnel = "http://" + event:param("tunnel") + "/"; | |
| } | |
| webhook:text(tunnel); | |
| fired { | |
| set app:tunnel tunnel; | |
| } | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // 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