Skip to content

Instantly share code, notes, and snippets.

@pubnub
Created May 6, 2011 23:24
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 pubnub/959998 to your computer and use it in GitHub Desktop.
Save pubnub/959998 to your computer and use it in GitHub Desktop.
PubNub HTML5 JavaScript Include Format
<html>
<head>
</head>
<body>
<div pub-key="pub-9160a90d-2a5a-4a60-9d51-36627c1b8fef" sub-key="sub-24a81de3-7809-11e0-902e-fd18c4107ffd" ssl="off" origin="pubsub.pubnub.com" id="pubnub"></div>
<script src="http://cdn.pubnub.com/pubnub-3.1.min.js"></script>
<script>(function(){
// LISTEN FOR MESSAGES
PUBNUB.subscribe({
channel : "hello_world", // CONNECT TO THIS CHANNEL.
error : function() { // LOST CONNECTION (auto reconnects)
alert("Connection Lost. Will auto-reconnect when Online.")
},
callback : function(message) { // RECEIVED A MESSAGE.
alert(message)
},
connect : function() { // CONNECTION ESTABLISHED.
// SEND MESSAGE
PUBNUB.publish({
channel : "hello_world",
message : "Hi from PubNub."
})
}
})
})();</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment