Skip to content

Instantly share code, notes, and snippets.

@ToeJamson
Created October 11, 2013 17:01
Show Gist options
  • Select an option

  • Save ToeJamson/6938336 to your computer and use it in GitHub Desktop.

Select an option

Save ToeJamson/6938336 to your computer and use it in GitHub Desktop.
Node.js Quick Start
<div pub-key="demo" sub-key="demo" id="pubnub"></div>
<script src="http://cdn.pubnub.com/pubnub-3.1.min.js"></script>
<script>(function(){
// Listen For Events
PUBNUB.subscribe({
channel : "hello_world", // Channel
error : function() { // Lost Connection (auto reconnects)
alert("Connection Lost. Will auto-reconnect when Online.")
},
callback : function(message) { // Received An Event.
alert(message.anything)
},
connect : function() { // Connection Established.
// Send Message
PUBNUB.publish({
channel : "hello_world",
message : { anything : "Hi from PubNub." }
})
}
})
})();</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment