Permalink
Browse files

Merge branch 'master' of https://github.com/pubnub/pubnub-api

  • Loading branch information...
2 parents 2456e13 + 2ec1e8e commit 9c90042264b90d6c012439f1c553527ef3bc758c geremy cohen committed Dec 4, 2012
@@ -1,9 +1,16 @@
body, h1, div, p {
font-family: "Helvetica Neue";
}
-h1 {
+h1, h2 {
+ color: #e15;
+ font-family: "Helvetica Neue";
font-size: 90px;
- text-shadow: 20px 20px 40px #444;
+ text-shadow: 20px 20px 40px #aaa;
+}
+h2 {
+ font-family: "Helvetica Neue";
+ font-weight: 200;
+ margin: 5px 0;
}
button {
cursor: pointer;
@@ -1,22 +1,15 @@
(function(){
var p = PUBNUB.init({ publish_key: 'demo', subscribe_key : 'demo' })
- , channel = 'my_channel'
- , btn = {
- image : p.$('image'),
- video : p.$('video'),
- html : p.$('html')
- };
+ , channel = 'my_directors_channel';
- function bind(button) {
- p.bind( 'mousedown,touchstart', button, function() {
- send(p.attr( button, 'source' ));
- } );
- }
-
- bind(btn.image);
- bind(btn.video);
- bind(btn.html);
+ p.bind( 'mousedown,touchstart', p.$('buttons'), function(e) {
+ var target = e.target || e.srcElement;
+ send(
+ p.attr( target, 'source' ) ||
+ p.attr( target.parentNode, 'source' )
+ );
+ } );
function send(data) {
p.publish({
@@ -6,11 +6,12 @@
</head>
<body>
-<button id=image class="button white" source='<img src="http://pubnub.s3.amazonaws.com/2011/powered-by-pubnub/powered-by-pubnub-600.png">'><img height=50 src="http://pubnub.s3.amazonaws.com/2011/powered-by-pubnub/powered-by-pubnub-600.png"></button>
-
-<button id=video class="button white" source='<iframe width="420" height="315" src="http://www.youtube.com/embed/jZgcEj_qKLU?autoplay=1" frameborder="0" allowfullscreen></iframe>'><img height=50 src="http://ctaar.rutgers.edu/images/Play_Icon.png"></button>
-
-<button id=html class="button white" source='<h1>WebRTC: Data Channels</h1>'><img height=50 src="http://www.w3.org/html/logo/downloads/HTML5_Logo_512.png"></button>
+<div id=buttons>
+ <button id=image class="button white" source='<img src="http://pubnub.s3.amazonaws.com/2011/powered-by-pubnub/powered-by-pubnub-600.png">'><img height=50 src="http://pubnub.s3.amazonaws.com/2011/powered-by-pubnub/powered-by-pubnub-600.png"></button>
+ <button id=video class="button white" source='<iframe width="720" height="560" src="http://www.youtube.com/embed/jZgcEj_qKLU?autoplay=1" frameborder="0" allowfullscreen></iframe>'><img height=50 src="play.png"></button>
+ <button id=html2 class="button white" source='<h1>BEYOND THE CALL</h1><h2>WebRTC</h2><h2>Data Channels</h2>'><img height=50 src="http://www.w3.org/html/logo/downloads/HTML5_Logo_512.png"></button>
+ <button id=html class="button white" source='<h1>READY NOW</h1><h2>WebRTC</h2><h2>Data Channels</h2>'><img height=50 src="http://www.w3.org/html/logo/downloads/HTML5_Logo_512.png"></button>
+</div>
<div class=stage id=output><div>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -1,15 +1,15 @@
-
##### YOU MUST HAVE A PUBNUB ACCOUNT TO USE THE API.
##### http://www.pubnub.com/account
-## PubNub 3.3 Real-time Cloud Push API - JAVA
+## PubNub 3.3 Real-time Cloud Push API - GWT
www.pubnub.com - PubNub Real-time Push Service in the Cloud.
http://www.pubnub.com/tutorial/java-push-api
Please reference the unit-tests and examples for usage on basic functionality,
including presence(), here_now(), and detailedHistory().
-JDK 1.7 required to run the precompiled tests and examples in 3.3/test. Example usage:
+To run the example app, copy the pubnubexample.war in gwt/3.3/examples/PubnubExample/ to the webapps dir of tomcat,
+and restart tomcat. Then visit <tomcat url>:<port>/pubnubexample/PubnubExample.html
-/opt/jdk1.7.0_04/bin/java -jar PubnubUnitTest.jar
+You can find a running demo of the example app running here: http://geremy.pubnub.com:8080/pubnubexample/PubnubExample.html
View
@@ -0,0 +1,153 @@
+# YOU MUST HAVE A PUBNUB ACCOUNT TO USE THE API.
+http://www.pubnub.com/account
+
+## TESTLING - (OPTIONAL)
+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.
+This is completely optional, however we love Testling.
+
+
+## PubNub 3.3.1 Real-time Cloud Push API - JAVASCRIPT
+http://www.pubnub.com - PubNub Real-time Push Service in the Cloud.
+http://www.pubnub.com/tutorial/javascript-push-api
+
+PubNub is a blazingly fast cloud-hosted messaging service for building
+real-time web and mobile apps. Hundreds of apps and thousands of developers
+rely on PubNub for delivering human-perceptive real-time
+experiences that scale to millions of users worldwide. PubNub delivers
+the infrastructure needed to build amazing MMO games, social apps,
+business collaborative solutions, and more.
+
+## SIMPLE EXAMPLE
+```html
+<div id=pubnub pub-key=demo sub-key=demo></div>
+<script src=http://cdn.pubnub.com/pubnub-3.3.1.min.js ></script>
+<script>
+
+ // LISTEN
+ PUBNUB.subscribe({
+ channel : "hello_world",
+ callback : alert
+ })
+
+ // SEND
+ PUBNUB.publish({
+ channel : "hello_world",
+ message : "Hi."
+ })
+
+</script>
+```
+
+## ADVANCED STYLE
+```html
+<div id=pubnub pub-key=demo sub-key=demo></div>
+<script src=http://pubnub.s3.amazonaws.com/pubnub-3.3.1.min.js ></script>
+<script>(function(){
+ // LISTEN FOR MESSAGES
+ PUBNUB.subscribe({
+ channel : "hello_world", // CONNECT TO THIS CHANNEL.
+ restore : false, // STAY CONNECTED, EVEN WHEN BROWSER IS CLOSED
+ // OR WHEN PAGE CHANGES.
+ callback : function(message) { // RECEIVED A MESSAGE.
+ alert(message)
+ },
+ connect : function() { // CONNECTION ESTABLISHED.
+ PUBNUB.publish({ // SEND A MESSAGE.
+ channel : "hello_world",
+ message : "Hi from PubNub."
+ })
+ },
+ disconnect : function() { // LOST CONNECTION.
+ alert(
+ "Connection Lost." +
+ "Will auto-reconnect when Online."
+ )
+ },
+ reconnect : function() { // CONNECTION RESTORED.
+ alert("And we're Back!")
+ },
+ presence : function(message) { // Presence() example (see console for logged output.)
+ console.log(message, true);
+ }
+ })
+})();
+
+</script>
+
+<span onclick="hereNow()">Click Me for Here Now!</span> // here_now() example (see console for logged output.)
+ <br/>
+<span onclick="history()">Click Me for History!</span> // detailedHistory() example (see console for logged output.)
+
+<script type="text/javascript">
+
+ function hereNow() {
+ PUBNUB.here_now({channel:'hello_world', callback:function (message) {
+ console.log(message);
+ }});
+ }
+
+ function history() {
+ PUBNUB.detailedHistory({count:10, channel:'hello_world', callback:function (message) {
+ console.log(message);
+ }});
+}
+
+
+</script>
+
+```
+
+## SSL MODE
+
+```html
+<div id=pubnub ssl=on></div>
+<script src=https://pubnub.a.ssl.fastly.net/pubnub-3.3.1.min.js></script>
+<script>(function(){
+
+ var pubnub = PUBNUB.init({
+ publish_key : 'demo',
+ subscribe_key : 'demo',
+ origin : 'pubsub.pubnub.com',
+ ssl : true
+ });
+
+ pubnub.subscribe({
+ channel : 'my_channel',
+ connect : function() { /* ... */ },
+ callback : function(message) {
+ alert(JSON.stringify(message));
+ }
+ });
+
+})();</script>
+```
+
+## Using the PUBNUB init() Function
+
+Sometimes you want to use create a PubNub Instance directly in JavaScript
+and pass the PubNub API Keys without using a DOM element.
+To do this, simply follow this `init` example:
+
+```html
+<script src=http://cdn.pubnub.com/pubnub-3.3.1.min.js ></script>
+<script>(function(){
+
+ // INIT PubNub
+ var pubnub = PUBNUB.init({
+ publish_key : 'demo',
+ subscribe_key : 'demo',
+ origin : 'pubsub.pubnub.com'
+ });
+
+ // LISTEN
+ pubnub.subscribe({ channel : "hello_world", callback : alert })
+
+ // SEND
+ pubnub.publish({ channel : "hello_world", message : "Hi." })
+
+})();</script>
+```
View
Binary file not shown.
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<cross-domain-policy>
+ <allow-access-from domain="*" secure="false" />
+</cross-domain-policy>
View
No changes.
Oops, something went wrong.

0 comments on commit 9c90042

Please sign in to comment.