Created
May 6, 2011 23:24
-
-
Save pubnub/959998 to your computer and use it in GitHub Desktop.
PubNub HTML5 JavaScript Include Format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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