Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Outline

PubNub HTML5 Modern JavaScript Library

v3.4.4

For a faster PubNub load, use the PubNub HTML5 Modern JavaScript Library which is CommonJS and HTML5 WebWorker Ready.

Supported Browsers:

  • firefox/3.6'
  • firefox/9.0'
  • firefox/10.0'
  • chrome/16.0'
  • chrome/17.0'
  • iexplore/9.0'
  • safari/5.1'
<script src=pubnub.min.js></script>
<script>(function(){
    // ----------------------------------
    // INIT PUBNUB
    // ----------------------------------
    var pubnub = PUBNUB({
        publish_key   : 'PUBLISH_KEY_HERE',
        subscribe_key : 'SUBSCRIBE_KEY_HERE',
        ssl           : false,
        origin        : 'pubsub.pubnub.com'
    });

    // ----------------------------------
    // LISTEN FOR MESSAGES
    // ----------------------------------
    pubnub.subscribe({
        restore  : true,
        connect  : send_hello,
        channel  : 'my_channel',
        callback : function(message) {
            console.log(JSON.stringify(message));
        },
        disconnect : function() {
            console.log("Connection Lost");
        }
    });

    // ----------------------------------
    // SEND MESSAGE
    // ----------------------------------
    function send_hello() {
        pubnub.publish({
            channel  : 'my_channel',
            message  : { example : "Hello World!" },
            callback : function(info) {
                console.log(JSON.stringify(info));
            }
        });
    }
})();</script>
Morty Proxy This is a proxified and sanitized view of the page, visit original site.