Created
May 13, 2013 20:40
-
-
Save anonymous/5571339 to your computer and use it in GitHub Desktop.
This file contains 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
<div>Ably Quickstart example</div> | |
<ul id="output"> | |
</ul> | |
Message: <input id="message" type="text" value="Hello"><br> | |
<input type="submit" id="publish" value="Publish the message"> | |
</html> |
This file contains 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 app = new Ably.Realtime('OPk-Mg.FpJlvg:wr_DvMODwpUXwrAc'); | |
app.on('connect', function() { | |
$('#output').append($('li').text("That was simple, we're now connected to Ably in realtime"); | |
}); | |
var channel = app.channel('quickstart'); | |
channel.on('greeting', function(data) { | |
$('#output').append($('li').text("Received a message: " + data)); | |
}); | |
$('#publish').on('click', function() { | |
channel.publish('greeting', $('#message').value()); | |
}) |
This file contains 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
name: Ably realtime example: quick-start-guide/send-message | |
authors: | |
- Ably.io | |
resources: | |
- http://code.jquery.com/jquery-1.9.1.min.js | |
normalize_css: no |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment