Created
April 2, 2011 17:57
-
-
Save trotter/899702 to your computer and use it in GitHub Desktop.
The Chloe example
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
| var chloe = new Chloe({host: "<%= server_name %>", port: 8901}); | |
| chloe.connect(function () { | |
| console.log('Holy crap, connected!'); | |
| chloe.send('Ohai Chloe!'); | |
| chloe.subscribe('pumpkin', function (message) { | |
| console.log('Someone was eating pumpkins: ' + message); | |
| }); | |
| }); |
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
| post '/updates' do | |
| data = request.body.read | |
| Net::HTTP.post_form(URI.parse("http://#{server_name}:8901/send"), | |
| {"data" => "Handled by Sinatra: #{data}"}) | |
| puts "I got some data: #{data}" | |
| "success" | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment