Switch branches/tags
Nothing to show
Find file History
Pull request Compare This branch is 1578 commits behind pubnub:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
..
Failed to load latest commit information.
examples
modules
README
comet.swf
crossdomain.xml
pubnub-3.1.js
pubnub-3.1.min.js
pubnub-websocket-beta-3.1.js
pubnub.as
pubnub.swf
test.js
test.sh

README

## ----------------------------------------------------
##
## YOU MUST HAVE A PUBNUB ACCOUNT TO USE THE API.
## http://www.pubnub.com/account-javascript-api-include
##
## USE "DEMO" INCLUDES (BELOW) FREE! WHILE DEVELOPING
##
## ----------------------------------------------------

## ----------------------------------------------------
##
## TESTLING - PubNub JavaScript API for Web Browsers
##            uses Testling Cloud Service
##            for QA and Deployment.
##
## http://www.testling.com/
## You need this to run './test.sh' unit test.
##
## ----------------------------------------------------

## ------------------------------------------------
## PubNub 3.1 Real-time Cloud Push API - JAVASCRIPT
## ------------------------------------------------
##
## www.pubnub.com - PubNub Real-time Push Service in the Cloud. 
## http://www.pubnub.com/tutorial/javascript-push-api
##
## PubNub is a Massively Scalable Real-time Service for Web and Mobile Games.
## This is a cloud-based service for broadcasting Real-time messages
## to thousands of web and mobile clients simultaneously.

<!-- ============================= -->
<!-- INCLUDE SCRIPT PREFERED STYLE -->
<!-- ============================= -->
<div
    id=pubnub
    pub-key=demo
    sub-key=demo
    ssl=off
    origin=pubsub.pubnub.com
></div>
<script src=http://cdn.pubnub.com/pubnub-3.1.min.js ></script>
<script>(function(){
    // ----------------------------------
    // LISTEN FOR MESSAGES
    // ----------------------------------
    PUBNUB.subscribe({
        channel  : 'test',
        callback : function(message) {
            console.log(JSON.stringify(message));
        },
        error : function() {
            // The internet is gone.
            console.log("Connection Lost");
        }
    });

    // ----------------------------------
    // SEND MESSAGE
    // ----------------------------------
    setInterval( function() {
        PUBNUB.publish({
            channel  : 'test',
            message  : { example : "Hello World!" },
            callback : function(info) {
                if (info[0])
                    console.log("Successfully Sent Message!");
                else
                    // The internet is gone.
                    console.log("Failed! -> " + info[1]);
            }
        });
    }, 1000 );
})();</script>

<!-- ============================= -->
<!-- SIMPLE EXAMPLE USE PUBNUB API -->
<!-- ============================= -->
<script>

    // -------------------
    // LISTEN FOR MESSAGES
    // -------------------
    PUBNUB.subscribe({
        channel  : "hello_world",
        callback : function(message) { alert(message) }
    })

    // ------------
    // SEND MESSAGE
    // ------------
    PUBNUB.publish({
        channel : "hello_world",
        message : "Hi."
    })

</script>