Skip to content

Instantly share code, notes, and snippets.

@mattheworiordan
Forked from anonymous/fiddle.html
Last active December 17, 2015 07:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattheworiordan/5571376 to your computer and use it in GitHub Desktop.
Save mattheworiordan/5571376 to your computer and use it in GitHub Desktop.
<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>
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());
})
name: Ably.io realtime example
description: Example code created by Ably.io
authors:
- Ably.io
resources:
- http://code.jquery.com/jquery-1.9.1.min.js
- http://cdn.ably.io/lib/ably.js
normalize_css: no
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment