Skip to content

Commit

Permalink
mx example
Browse files Browse the repository at this point in the history
  • Loading branch information
geremy cohen committed Nov 2, 2012
1 parent 55f784e commit cbff508
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions javascript-modern/3.3/tests/mx_example.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>

<script src=../pubnub-3.3-common.js></script>
<script src=../pubnub-3.3.js></script>

<script>

var setup = {"origin":"multiplexing.pubnub.com", "subscribe_key":"demo", "publish_key":"demo"};
var p = PUBNUB(setup);

// LISTEN
p.subscribe({
channel:"mx_a,mx_b,mx_c",
callback:function (msg) {
console.log(msg)
},
connect:publish_to_mx_a
})

//alert("Watch console.log for receipt of three publishes on a single channel!");

function publish_to_mx_a() {
// Publish to channel a
p.publish({
channel:"mx_a",
message:"Vitamin A (or Vitamin A Retinol, retinal, and four!",
callback:publish_to_mx_b
})
}


// Publish to channel b

function publish_to_mx_b() {
p.publish({
channel:"mx_b",
message:"Vitamin B vitamins are a group of water-soluble!",
callback:publish_to_mx_c
});
}

function publish_to_mx_c() {
// Publish to channel c
p.publish({
channel:"mx_c",
message:"Vitamin C or L-ascorbic acid, or simply ascorbate!"
})
}

</script>

0 comments on commit cbff508

Please sign in to comment.