Skip to content

Commit

Permalink
Step 4 - Publishing messages to be stored with history
Browse files Browse the repository at this point in the history
  • Loading branch information
mattheworiordan committed Sep 3, 2016
1 parent a55b855 commit f460ba7
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions example.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<html>
<body>
<h1>Publish Subscribe example</h1>
<button id="publish">Publish sound messages</button>
</body>

<!-- Include the latest Ably Library -->
Expand All @@ -10,5 +11,15 @@ <h1>Publish Subscribe example</h1>
<script type="text/javascript">
alert("You need to add your API key"); /* REMOVE THIS */
var realtime = new Ably.Realtime("INSERT-YOUR-API-KEY-HERE"); /* ADD YOUR API KEY HERE */

/* Get a channel in the "persisted" namespace */
var channel = realtime.channels.get("persisted:sounds");

/* Publish three messages when the publish button is clicked */
document.getElementById("publish").addEventListener("click", function() {
channel.publish("play", "bark");
channel.publish("play", "meow");
channel.publish("play", "cluck");
});
</script>
</html>

0 comments on commit f460ba7

Please sign in to comment.