Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added Socket.IO to JavaScript Repository.

  • Loading branch information...
commit d42ac79c20eef58043abe89734effda8868607e1 1 parent 99b51a9
@stephenlb stephenlb authored
Showing with 3,635 additions and 5 deletions.
  1. +15 −5 build-all
  2. +491 −0 socket.io/README.md
  3. +40 −0 socket.io/acknowledgements/app.js
  4. +26 −0 socket.io/acknowledgements/index.html
  5. +4 −0 socket.io/acknowledgements/styles.css
  6. +35 −0 socket.io/bootstrap-mobile/app.js
  7. BIN  socket.io/bootstrap-mobile/icon.png
  8. +34 −0 socket.io/bootstrap-mobile/index.html
  9. BIN  socket.io/bootstrap-mobile/startup.png
  10. +4 −0 socket.io/bootstrap-mobile/styles.css
  11. +35 −0 socket.io/bootstrap-web/app.js
  12. +21 −0 socket.io/bootstrap-web/index.html
  13. +4 −0 socket.io/bootstrap-web/styles.css
  14. +4 −0 socket.io/build
  15. +42 −0 socket.io/crypto.js
  16. +49 −0 socket.io/custom-presence/app.js
  17. +21 −0 socket.io/custom-presence/index.html
  18. +4 −0 socket.io/custom-presence/styles.css
  19. +40 −0 socket.io/encryption/app.js
  20. +21 −0 socket.io/encryption/index.html
  21. +4 −0 socket.io/encryption/styles.css
  22. +36 −0 socket.io/hello-world/app.js
  23. +21 −0 socket.io/hello-world/index.html
  24. +4 −0 socket.io/hello-world/styles.css
  25. +38 −0 socket.io/here_now/app.js
  26. +25 −0 socket.io/here_now/index.html
  27. +4 −0 socket.io/here_now/styles.css
  28. +51 −0 socket.io/history/app.js
  29. +25 −0 socket.io/history/index.html
  30. +4 −0 socket.io/history/styles.css
  31. +35 −0 socket.io/multiplexing/app.js
  32. +21 −0 socket.io/multiplexing/index.html
  33. +4 −0 socket.io/multiplexing/styles.css
  34. +29 −0 socket.io/non-socket-io-communication/README.md
  35. +30 −0 socket.io/non-socket-io-communication/app.js
  36. BIN  socket.io/non-socket-io-communication/icon.png
  37. +48 −0 socket.io/non-socket-io-communication/index.html
  38. BIN  socket.io/non-socket-io-communication/startup.png
  39. +4 −0 socket.io/non-socket-io-communication/styles.css
  40. +38 −0 socket.io/presence/app.js
  41. +23 −0 socket.io/presence/index.html
  42. +4 −0 socket.io/presence/styles.css
  43. +60 −0 socket.io/public-private-communication/public-private-communication.html
  44. +142 −0 socket.io/public-private-communication/public-private-communication.js
  45. +92 −0 socket.io/simple-button/app.js
  46. BIN  socket.io/simple-button/icon.png
  47. +49 −0 socket.io/simple-button/index.html
  48. BIN  socket.io/simple-button/notify.mp3
  49. BIN  socket.io/simple-button/notify.ogg
  50. BIN  socket.io/simple-button/startup.png
  51. +146 −0 socket.io/simple-button/styles.css
  52. +262 −0 socket.io/socket.io.js
  53. +1,270 −0 socket.io/socket.io.min.js
  54. BIN  socket.io/socket.io.min.js.gz
  55. +55 −0 socket.io/unit-test/unit-test.html
  56. +221 −0 socket.io/unit-test/unit-test.js
View
20 build-all
@@ -9,13 +9,13 @@ MINOUT=pubnub-$VERSION.min.js
if [ -z "$googleminify" ]; then googleminify="/opt/minify/compiler.jar"; fi
-echo -e " "
-echo -e " USING: $googleminify TO MINIFY..."
-echo -e " COMPILING PUBNUB JAVASCRIPT API..."
+echo -e " USING: $googleminify"
## -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
## Web Build
## -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+echo -e " "
+echo -e " BUILDING WEB..."
rm ./web/pubnub-$VERSION*
echo -n "// " >> ./web/$TOPOUT
cat ./VERSION ./core/json.js ./core/pubnub.js ./core/websocket.js >> ./web/$TOPOUT
@@ -24,9 +24,19 @@ cat ./VERSION >> ./web/$MINOUT
echo "(function(){" >> ./web/$MINOUT
java -jar $googleminify --js=./web/$TOPOUT --compilation_level=ADVANCED_OPTIMIZATIONS >> ./web/$MINOUT
echo "})();" >> ./web/$MINOUT
-echo -e " >>COMPRESSING<< PUBNUB JAVASCRIPT API..."
cp ./web/$TOPOUT ./web/pubnub.js
cp ./web/$MINOUT ./web/pubnub.min.js
-echo -e " "
echo -e " DONE WEB BUILD!\n"
+## -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+## Socket.IO Build
+## -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+echo -e " "
+echo -e " BUILDING SOCKET.IO..."
+cat ./socket.io/socket.io.js | java -jar $googleminify > ./socket.io/socket.io.tmp
+cat ./web/pubnub.min.js \
+ ./core/crypto/gibberish-aes.js \
+ ./core/crypto/encrypt-pubnub.js \
+ ./socket.io/socket.io.tmp > ./socket.io/socket.io.min.js
+rm ./socket.io/socket.io.tmp
+echo -e " DONE SOCKET.IO BUILD!\n"
View
491 socket.io/README.md
@@ -0,0 +1,491 @@
+# Socket.IO on PubNub
+
+Get a faster Socket.IO with PubNub! Take advantage of the Socket.IO API
+leveraging Human Perceptive Real-time on PubNub Infrastructure.
+We believe Socket.IO is the jQuery of Networking.
+Socket.IO is a project that makes WebSockets and Real-time possible in
+all browsers. It also enhances WebSockets by providing built-in multiplexing,
+automatic scalability, automatic JSON encoding/decoding, and
+even more with PubNub.
+
+## Enhanced Socket.IO with PubNub
+
+![Socket.IO on PubNub](http://pubnub.s3.amazonaws.com/assets/socket.io-enhanced-with-pubnub.png "Socket.IO on PubNub")
+
+We enhanced Socket.IO with PubNub.
+Faster JavaScript, Smaller Footprint, Faster Cloud Network and
+Socket.IO with PubNub does not require a Node.JS backend.
+This means your code is lean and
+simple giving you extra time to build your app.
+The updated JS payload has been optimized for Mobile Apps;
+which means excellent performance for laptops too.
+
+## SOCKET.IO VIMEO CHANNEL
+
++ [Socket.IO Vimeo Channel](https://vimeo.com/channels/291682)
+## VIDEO TUTORIALS
+
++ ./presence/ - [Presence Tutorial.](http://vimeo.com/pubnub/socket-io-pubnub-user-presence)
++ ./bootstrap-mobile/ - [Bootstrap for Mobile iPhone/Android Apps.](http://vimeo.com/pubnub/socket-io-pubnub-get-started-with-a-bootstrap)
++ ./bootstrap-web/ - [Bootstrap for Desktop/Tablet Web Apps.](http://vimeo.com/pubnub/socket-io-pubnub-get-started-with-a-bootstrap)
++ ./unit-test/ - [Unit Test for Socket.IO on PubNub.](http://vimeo.com/pubnub/socket-io-pubnub-unit-test)
++ ./simple-button/ - [Simple Button App for learning PubNub.](http://vimeo.com/pubnub/socket-io-pubnub-simple-button)
++ ./multiplexing/ - [Multiplexing Tutorial.](http://vimeo.com/pubnub/socket-io-pubnub-socket-multiplexing)
++ ./encryption/ - [Encryption Tutorial.](http://vimeo.com/pubnub/socket-io-on-pubnub-encryption)
++ ./acknowledgements/ - [Acknowledgements Tutorial.](http://vimeo.com/pubnub/socket-io-pubnub-acknowledgement-of-message-receipt)
+
+## BACKGROUND VIDEO
+
++ [Origin of Socket.IO on PubNub](http://vimeo.com/pubnub/socket-io-pubnub-origin-of-socket-io)
+
+## Simplified Socket.IO API Usage
+
+By default, all messages are broadcast. This means when you use
+emit() or send() functions, the message will be broadcast.
+
+## New and Simplifed Features with Socket.IO on PubNub
+
++ Full Security Mode with SSL at 2048bit by PubNub.
++ Enhanced User Tracking Presence Events (join, leave).
++ Disable Presence (join, leave).
++ Get Counts of Active Users per Connection.
++ Get a List of Active Users.
++ Customer User Data.
++ Socket level Events (connect, disconnect, reconnect).
++ Multiplexing many channels on one socket.
++ Multiple Event Binding on one socket.
++ Smart Broadcasting (broadcast with auto-recovery on failure).
++ Disconnect from a Channel.
++ Acknowledgements of Message Receipt.
++ Stanford Crypto Library with AES Encryption.
++ Server Side Events.
++ Geo Data with Latitude/Longitude.
+
+## How to use
+
+First, include `pubnub.js` and `socket.io.js`:
+
+```html
+<script src="http://cdn.pubnub.com/socket.io.min.js"></script>
+<script>
+ var socket = io.connect('http://pubsub.pubnub.com');
+ socket.on( 'news', function (data) {
+ console.log(data);
+ } );
+</script>
+```
+
+This simplified usage of Socket.IO will create a connection, listen for a
+`news` event and log the data to the console.
+
+## Short recipes
+
+### Sending and receiving events.
+
+Socket.IO allows you to emit and receive custom events.
+Reserved Events are: `connect`, `message`, `disconnect`,
+`reconnect`, `ping`, `join` and `leave`.
+
+```js
+// IMPORTANT: PubNub Setup with Account
+var pubnub_setup = {
+ channel : 'my_mobile_app',
+ publish_key : 'demo',
+ subscribe_key : 'demo'
+};
+
+var socket = io.connect( 'http://pubsub.pubnub.com', pubnub_setup );
+
+socket.on( 'connect', function() {
+ console.log('Connection Established! Ready to send/receive data!');
+ socket.send('my message here');
+ socket.send(1234567);
+ socket.send([1,2,3,4,5]);
+ socket.send({ apples : 'bananas' });
+} );
+
+socket.on( 'message', function(message) {
+ console.log(message);
+} );
+
+socket.on( 'disconnect', function() {
+ console.log('my connection dropped');
+} );
+
+// Extra event in Socket.IO provided by PubNub
+socket.on( 'reconnect', function() {
+ console.log('my connection has been restored!');
+} );
+```
+
+### User Presence (Room Events: join, leave)
+
+>NOTE: You must enable presence on your PubNub account before this feature is available! Contact your Account Representative.
+
+Sometimes you want to put certain sockets in the same room, so that it's easy
+to broadcast to all of them together.
+
+Think of this as built-in channels for sockets. Sockets `join` and `leave`
+rooms in each channel.
+
+```js
+var chat = io.connect( 'http://pubsub.pubnub.com/chat', pubnub_setup );
+chat.on( 'leave', function(user) {
+ console.log( 'user left', user );
+} );
+chat.on( 'join', function(user) {
+ console.log( 'user joined', user );
+} );
+```
+### Disable User Presence (Room Events: join, leave)
+
+Maybe you do not need to spend the extra message consumption rates of
+Sending/Receiving messages for User Join/Leave events. If this is the case,
+you will want to disable presenece detection. This saves you a lot of messages.
+
+```js
+var pubnub_setup = {
+ channel : 'my_mobile_app',
+ presence : false, // DISABLE PRESENCE HERE
+ publish_key : 'demo',
+ subscribe_key : 'demo'
+};
+var chat = io.connect( 'http://pubsub.pubnub.com/chat', pubnub_setup );
+```
+
+
+### Custom User Presence (Custom User Data)
+
+Optionally you may need to supply specific details
+about a user who has connected
+or disconnected recently, or ongoign during usage of the app.
+This is because you have a database with user details in a table
+like MongoDB, CouchDB, MySQL, Redis or another.
+And you want to share these details over the wire
+on Join/Leave events with other connected users.
+The best way to relay custom user details is to
+use this following sample code:
+
+```js
+var MY_USER_DATA = { name : "John" };
+var pubnub_setup = {
+ user : MY_USER_DATA,
+ channel : 'my_mobile_app',
+ publish_key : 'demo',
+ subscribe_key : 'demo'
+};
+var chat = io.connect( 'http://pubsub.pubnub.com/chat', pubnub_setup );
+chat.on( 'leave', function(user) {
+ // Print and User Data from Other Users
+ console.log( 'user left', user.data );
+} );
+chat.on( 'join', function(user) {
+ // Print and User Data from Other Users
+ console.log( 'user joined', user.data );
+} );
+
+// Change User Details after 5 Seconds
+// All Connected users will receive the update.
+setTimeout( function() {
+ MY_USER_DATA.name = "Sam";
+}, 5000 );
+```
+
+### Enabling SSL
+
+Enabling security is important, right?
+Get started easily by following these four steps:
+
+1. Add On-Page DIV `<div id=pubnub ssl=on></div>`.
+2. Point to HTTPS Script `https://dh15atwfs066y.cloudfront.net/socket.io.min.js`.
+3. Set `ssl : true` in `pubnub_setup` var.
+4. Set HTTPS `https://` in `io.connect()` function.
+
+```html
+<!-- 1.) ENABLE SECURE CONNECTIONS FOR THIS PAGE -->
+<div id=pubnub ssl=on></div>
+
+<!-- 2.) Use PubNub CDN HTTPS URL -->
+<script src=https://dh15atwfs066y.cloudfront.net/socket.io.min.js></script>
+
+<script>(function(){
+
+var pubnub_setup = {
+ channel : 'my_mobile_app',
+ publish_key : 'demo',
+ subscribe_key : 'demo',
+ ssl : true // 3.) Set SSL to true
+};
+
+// 4.) Set Transport to HTTPS
+var chat = io.connect( 'https://pubsub.pubnub.com/chat', pubnub_setup );
+
+chat.on( 'join', function(user) {
+ console.log( 'user joined:', user );
+} );
+chat.on( 'leave', function(user) {
+ console.log( 'user left:', user );
+} );
+
+})();</script>
+```
+
+### User Geo Data with Latitude/Longitude
+
+Do you need Geographical Coordinate Data from which your users are
+communicating from?
+
+```js
+var pubnub_setup = {
+ channel : 'my_mobile_app',
+ publish_key : 'demo',
+ subscribe_key : 'demo',
+ geo : true // <--- Geo Flag!!!
+};
+
+var chat = io.connect( 'http://pubsub.pubnub.com/chat', pubnub_setup );
+
+chat.on( 'join', function(user) {
+ console.log( 'user joined from:', user.geo );
+} );
+chat.on( 'leave', function(user) {
+ console.log( 'user left from:', user.geo );
+} );
+```
+
+If a user joins after a group has already formed,
+a `join` event will be fired for each user already connected.
+
+### Enhanced Presence with User Counts & Lists.
+
+Often you will want to know how many users are connected to a channel (room).
+To get this information you simply access the `get_user_count()` function.
+
+```js
+var chat = io.connect( 'http://pubsub.pubnub.com/chat', pubnub_setup );
+chat.on( 'leave', function(user) {
+ console.log(
+ 'User left. There are %d user(s) remaining.',
+ chat.get_user_count(),
+ chat.get_user_list()
+ );
+} );
+chat.on( 'join', function(user) {
+ console.log(
+ 'User joined! There are %d user(s) online.',
+ chat.get_user_count(),
+ chat.get_user_list()
+ );
+} );
+```
+
+### Restricting yourself to a namespace
+
+If you have control over all the messages and events emitted for a particular
+application, using the default `/` namespace works.
+
+If you want to leverage 3rd-party code, or produce code to share with others,
+socket.io provides a way of namespacing a `socket`.
+
+This has the benefit of `multiplexing` a single connection. Instead of
+socket.io using two `WebSocket` connections, it'll use one.
+
+The following example defines a socket that listens on '/chat' and one for
+'/news':
+
+```html
+<script>
+ var chat = io.connect('http://pubsub.pubnub.com/chat')
+ , news = io.connect('http://pubsub.pubnub.com/news');
+
+ chat.on('connect', function () {
+ chat.emit('hi!');
+ });
+
+ news.on('news', function () {
+ news.emit('woot');
+ });
+</script>
+```
+
+### Stanford Encryption AES
+
+To keep super secret messages private, you can use the `password` feature
+of Socket.IO on PubNub. You will be able to encrypt and decrypt
+automatically `client side`. This means all data transmitted is encrypted
+and unreadable to everyone without the correct password.
+
+It is simply to have data encrypted and automatically decrypt on receipt.
+Simply add the `password` entry in the `pubnub_setup` object.
+
+IMPORTANT: you must include the `cyrpto.js` library!
+
+```html
+<script src="http://cdn.pubnub.com/socket.io.min.js"></script>
+<script>
+ // Include a Password in the PubNub Setup Object.
+ var pubnub_setup = {
+ channel : 'my_mobile_app',
+ publish_key : 'demo',
+ subscribe_key : 'demo',
+ password : 'MY-PASSWORD' // Encrypt with Password
+ };
+
+ // Setup Encrypted Channel
+ var encrypted = io.connect(
+ 'http://pubsub.pubnub.com/secret',
+ pubnub_setup
+ );
+
+ // Listen for Connection Ready
+ encrypted.on( 'connect', function() {
+ // Send an Encrypted Messsage
+ encrypted.send({ my_secure_data : 'Super Secret!' });
+ } );
+
+ // Receive Encrypted Messages
+ encrypted.on( 'message', function(message) {
+ // Print Decrypted Data
+ console.log(message.my_secure_data);
+ } );
+</script>
+```
+
+This feature will automatically encrypt and decrypt messages
+using the Stanford JavaScript Crypto Library with AES.
+You can mix `encrypted` and `unencrypted` channels with the
+channel multiplexing feature by excluding a password from the
+`pubnub_setup` object when setting up a new connection.
+
+NOTE: If a password doesn't match, then the message will *not* be received.
+Make sure authorized users have the correct password!
+
+### Using it just as a cross-browser WebSocket
+
+If you just want the WebSocket semantics, you can do that too.
+Simply leverage `send` and listen on the `message` event:
+
+```html
+<script>
+ var socket = io.connect('http://pubsub.pubnub.com/');
+ socket.on('connect', function () {
+ socket.send('hi');
+
+ socket.on('message', function (msg) {
+ // my msg
+ });
+ });
+</script>
+```
+
+### Getting Acknowledgements (Receipt Confirmation)
+
+Sometimes, you might want to get a callback when the message was sent
+with success status. Note that this does not confirm that the message
+was recieved by other clients. This only acknowledges that the message
+was received by the PubNub Cloud.
+
+```js
+ var socket = io.connect(); // TIP: auto-discovery
+ socket.on( 'connect', function () {
+ socket.emit( 'important-message', { data : 1234 }, function (receipt) {
+ // Message Delivered Successfully!
+ console.log(receipt);
+ });
+ });
+```
+
+### Sending Events from a Server
+
+This example shows you how to send events to your Socket.IO clients
+using other PubNub libraries. We are using the simple syntax of `Python`
+here for the example:
+
+```python
+from PubNub import PubNub
+
+## Create a PubNub Object
+pubnub = PubNub( 'demo', 'demo', None, False )
+
+## Publish To Socket.IO
+pubnub.publish({
+ 'channel' : 'my_pn_channel',
+ 'message' : {
+ "name" : "message", ## Event Name
+ "ns" : "example-ns-my_pn_channel", ## Namespace
+ "data" : { "my" : "data" } ## Your Message
+ }
+})
+
+```
+
+The `Python` code above will send a message to your Socket.IO clients.
+Make sure that the client is connected first.
+
+```js
+// Use PubNub Setup for Your PubNub Account
+var pubnub_setup = {
+ channel : 'my_pn_channel',
+ publish_key : 'demo',
+ subscribe_key : 'demo'
+};
+
+var chat = io.connect( 'http://pubsub.pubnub.com/chat', pubnub_setup );
+
+chat.on( 'connect', function(message) {
+ console.log('ready to receive messages...');
+} );
+
+chat.on( 'message', function(message) {
+ // Received Message from Server!
+ console.log(message);
+} );
+```
+
+When you combine the `JavaScript` Socket.IO example with `Python`, you
+have the ablity to send messages to the client directly from your web server
+or terminal!
+
+## Revisions (REV)
+
+#### Security Patch Upgrade (Namespacing)
+
+A security patch was applied to the `namespacing` properties of PubNub
+Socket.IO provding an improved separation between channel names and
+multiplexed connectivity. This upgrade made a fundamental change to the
+`namespacing` scheme that will require an upgrade to your server side logic.
+For updated details, see [Server Sent Events](#sending-events-from-a-server).
+
+Also review a dedicated example of sending data into Socket.IO from the
+standard PubNub libraries or the HTTP REST API -
+[Non-Socket.IO Communication](https://github.com/pubnub/pubnub-api/tree/master/socket.io/non-socket-io-communication)
+
+## License
+
+(The MIT License)
+
+Copyright (c) 2011 PubNub Inc.
+
+Copyright (c) 2011 Guillermo Rauch <guillermo@learnboost.com>
+
+![Socket.IO on PubNub](http://pubnub.s3.amazonaws.com/assets/socket.io-on-pubnub-2.png "Socket.IO on PubNub")
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+'Software'), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
View
40 socket.io/acknowledgements/app.js
@@ -0,0 +1,40 @@
+(function(){
+
+// -----------------------------------------------------------------------
+// PUBNUB SETUP
+// -----------------------------------------------------------------------
+var pubnub_setup = {
+ channel : 'bootstrap-app',
+ publish_key : 'demo',
+ subscribe_key : 'demo'
+};
+
+// -----------------------------------------------------------------------
+// CREATE CONNECTION FOR USER EVENTS
+// -----------------------------------------------------------------------
+var socket = io.connect( 'http://pubsub.pubnub.com/events', pubnub_setup );
+
+// -----------------------------------------------------------------------
+// WAIT FOR A CONNECTION
+// -----------------------------------------------------------------------
+socket.on( 'connect', function() {
+
+ // Connected!!!
+ socket.send( 'my message very important that you got it....', function(info) {
+ // [1,"Unable to delivery do to stupid internt not working."]
+ console.log( JSON.stringify(info) );
+ } );
+
+} );
+
+// -----------------------------------------------------------------------
+// RECEIVE A MESSAGE
+// -----------------------------------------------------------------------
+socket.on( 'message', function(message) {
+
+ // Received a Message!
+ console.log(message);
+
+} );
+
+})();
View
26 socket.io/acknowledgements/index.html
@@ -0,0 +1,26 @@
+<!doctype html>
+<html>
+<head>
+ <!-- Hey, let's be friends! twitter.com/pubnub -->
+ <meta http-equiv=content-type content=text/html;charset=utf-8>
+ <title>PubNub ★ Socket.IO Bootstrap</title>
+ <link
+ href=http://fonts.googleapis.com/css?family=Open+Sans:400,700
+ rel=stylesheet>
+ <link href=styles.css rel=stylesheet>
+</head>
+<body>
+
+<!-- Place Content Here -->
+<div>Hello to Web User!</div>
+<!-- Place Content Here -->
+
+<!--
+<script src=../../javascript/pubnub-3.4.min.js></script>
+<script src=../crypto.js></script>
+<script src=../socket.io.js></script>
+-->
+<script src=../socket.io.min.js></script>
+<script src=app.js></script>
+</body>
+</html>
View
4 socket.io/acknowledgements/styles.css
@@ -0,0 +1,4 @@
+body {
+ font-family: "Open Sans";
+}
+
View
35 socket.io/bootstrap-mobile/app.js
@@ -0,0 +1,35 @@
+(function(){
+
+// -----------------------------------------------------------------------
+// PUBNUB SETUP
+// -----------------------------------------------------------------------
+var pubnub_setup = {
+ channel : 'bootstrap-app',
+ publish_key : 'demo',
+ subscribe_key : 'demo'
+};
+
+// -----------------------------------------------------------------------
+// CREATE CONNECTION FOR USER EVENTS
+// -----------------------------------------------------------------------
+var socket = io.connect( 'http://pubsub.pubnub.com/events', pubnub_setup );
+
+// -----------------------------------------------------------------------
+// WAIT FOR A CONNECTION
+// -----------------------------------------------------------------------
+socket.on( 'connect', function() {
+
+ // Connected!!!
+
+} );
+
+// -----------------------------------------------------------------------
+// RECEIVE A MESSAGE
+// -----------------------------------------------------------------------
+socket.on( 'message', function(message) {
+
+ // Received a Message!
+
+} );
+
+})();
View
BIN  socket.io/bootstrap-mobile/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
34 socket.io/bootstrap-mobile/index.html
@@ -0,0 +1,34 @@
+<!doctype html>
+<html>
+<head>
+ <!-- Hey, let's be friends! twitter.com/pubnub -->
+ <meta http-equiv=content-type content=text/html;charset=utf-8>
+
+ <meta name=viewport content=width=device-width>
+ <meta name=viewport content=initial-scale=1.0>
+ <meta name=viewport content=user-scalable=no>
+
+ <meta name=apple-mobile-web-app-capable content=yes>
+ <meta name=apple-mobile-web-app-status-bar-style content=black>
+
+ <link rel=apple-touch-icon href=icon.png>
+ <link rel=apple-touch-startup-image href=startup.png>
+
+ <title>PubNub ★ Socket.IO Bootstrap</title>
+
+ <link
+ href=http://fonts.googleapis.com/css?family=Open+Sans:400,700
+ rel=stylesheet>
+ <link href=styles.css rel=stylesheet>
+</head>
+<body>
+
+<!-- Place Content Here -->
+<div>Hello iPhone/Android User!</div>
+<!-- Place Content Here -->
+
+<script>scrollTo(0,1);</script>
+<script src=http://pubnub.s3.amazonaws.com/socket.io.min.js></script>
+<script src=app.js></script>
+</body>
+</html>
View
BIN  socket.io/bootstrap-mobile/startup.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
4 socket.io/bootstrap-mobile/styles.css
@@ -0,0 +1,4 @@
+body {
+ font-family: "Open Sans";
+}
+
View
35 socket.io/bootstrap-web/app.js
@@ -0,0 +1,35 @@
+(function(){
+
+// -----------------------------------------------------------------------
+// PUBNUB SETUP
+// -----------------------------------------------------------------------
+var pubnub_setup = {
+ channel : 'bootstrap-app',
+ publish_key : 'demo',
+ subscribe_key : 'demo'
+};
+
+// -----------------------------------------------------------------------
+// CREATE CONNECTION FOR USER EVENTS
+// -----------------------------------------------------------------------
+var socket = io.connect( 'http://pubsub.pubnub.com/events', pubnub_setup );
+
+// -----------------------------------------------------------------------
+// WAIT FOR A CONNECTION
+// -----------------------------------------------------------------------
+socket.on( 'connect', function() {
+
+ // Connected!!!
+
+} );
+
+// -----------------------------------------------------------------------
+// RECEIVE A MESSAGE
+// -----------------------------------------------------------------------
+socket.on( 'message', function(message) {
+
+ // Received a Message!
+
+} );
+
+})();
View
21 socket.io/bootstrap-web/index.html
@@ -0,0 +1,21 @@
+<!doctype html>
+<html>
+<head>
+ <!-- Hey, let's be friends! twitter.com/pubnub -->
+ <meta http-equiv=content-type content=text/html;charset=utf-8>
+ <title>PubNub ★ Socket.IO Bootstrap</title>
+ <link
+ href=http://fonts.googleapis.com/css?family=Open+Sans:400,700
+ rel=stylesheet>
+ <link href=styles.css rel=stylesheet>
+</head>
+<body>
+
+<!-- Place Content Here -->
+<div>Hello to Web User!</div>
+<!-- Place Content Here -->
+
+<script src=http://pubnub.s3.amazonaws.com/socket.io.min.js></script>
+<script src=app.js></script>
+</body>
+</html>
View
4 socket.io/bootstrap-web/styles.css
@@ -0,0 +1,4 @@
+body {
+ font-family: "Open Sans";
+}
+
View
4 socket.io/build
@@ -0,0 +1,4 @@
+#!/bin/bash
+cat ./socket.io.js | java -jar /opt/minify/compiler.jar > socket.io.tmp
+cat ../javascript/pubnub-3.4.1.min.js crypto.js socket.io.tmp > socket.io.min.js
+rm socket.io.tmp
View
42 socket.io/crypto.js
@@ -0,0 +1,42 @@
+(function(){
+"use strict";var sjcl=window['sjcl']={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(a){this.toString=function(){return"CORRUPT: "+this.message};this.message=a},invalid:function(a){this.toString=function(){return"INVALID: "+this.message};this.message=a},bug:function(a){this.toString=function(){return"BUG: "+this.message};this.message=a},notReady:function(a){this.toString=function(){return"NOT READY: "+this.message};this.message=a}}};
+sjcl.cipher.aes=function(a){this.h[0][0][0]||this.w();var b,c,d,e,f=this.h[0][4],g=this.h[1];b=a.length;var h=1;if(b!==4&&b!==6&&b!==8)throw new sjcl.exception.invalid("invalid aes key size");this.a=[d=a.slice(0),e=[]];for(a=b;a<4*b+28;a++){c=d[a-1];if(a%b===0||b===8&&a%b===4){c=f[c>>>24]<<24^f[c>>16&255]<<16^f[c>>8&255]<<8^f[c&255];if(a%b===0){c=c<<8^c>>>24^h<<24;h=h<<1^(h>>7)*283}}d[a]=d[a-b]^c}for(b=0;a;b++,a--){c=d[b&3?a:a-4];e[b]=a<=4||b<4?c:g[0][f[c>>>24]]^g[1][f[c>>16&255]]^g[2][f[c>>8&255]]^
+g[3][f[c&255]]}};
+sjcl.cipher.aes.prototype={encrypt:function(a){return this.H(a,0)},decrypt:function(a){return this.H(a,1)},h:[[[],[],[],[],[]],[[],[],[],[],[]]],w:function(){var a=this.h[0],b=this.h[1],c=a[4],d=b[4],e,f,g,h=[],i=[],k,j,l,m;for(e=0;e<0x100;e++)i[(h[e]=e<<1^(e>>7)*283)^e]=e;for(f=g=0;!c[f];f^=k||1,g=i[g]||1){l=g^g<<1^g<<2^g<<3^g<<4;l=l>>8^l&255^99;c[f]=l;d[l]=f;j=h[e=h[k=h[f]]];m=j*0x1010101^e*0x10001^k*0x101^f*0x1010100;j=h[l]*0x101^l*0x1010100;for(e=0;e<4;e++){a[e][f]=j=j<<24^j>>>8;b[e][l]=m=m<<24^m>>>8}}for(e=
+0;e<5;e++){a[e]=a[e].slice(0);b[e]=b[e].slice(0)}},H:function(a,b){if(a.length!==4)throw new sjcl.exception.invalid("invalid aes block size");var c=this.a[b],d=a[0]^c[0],e=a[b?3:1]^c[1],f=a[2]^c[2];a=a[b?1:3]^c[3];var g,h,i,k=c.length/4-2,j,l=4,m=[0,0,0,0];g=this.h[b];var n=g[0],o=g[1],p=g[2],q=g[3],r=g[4];for(j=0;j<k;j++){g=n[d>>>24]^o[e>>16&255]^p[f>>8&255]^q[a&255]^c[l];h=n[e>>>24]^o[f>>16&255]^p[a>>8&255]^q[d&255]^c[l+1];i=n[f>>>24]^o[a>>16&255]^p[d>>8&255]^q[e&255]^c[l+2];a=n[a>>>24]^o[d>>16&
+255]^p[e>>8&255]^q[f&255]^c[l+3];l+=4;d=g;e=h;f=i}for(j=0;j<4;j++){m[b?3&-j:j]=r[d>>>24]<<24^r[e>>16&255]<<16^r[f>>8&255]<<8^r[a&255]^c[l++];g=d;d=e;e=f;f=a;a=g}return m}};
+sjcl.bitArray={bitSlice:function(a,b,c){a=sjcl.bitArray.P(a.slice(b/32),32-(b&31)).slice(1);return c===undefined?a:sjcl.bitArray.clamp(a,c-b)},extract:function(a,b,c){var d=Math.floor(-b-c&31);return((b+c-1^b)&-32?a[b/32|0]<<32-d^a[b/32+1|0]>>>d:a[b/32|0]>>>d)&(1<<c)-1},concat:function(a,b){if(a.length===0||b.length===0)return a.concat(b);var c=a[a.length-1],d=sjcl.bitArray.getPartial(c);return d===32?a.concat(b):sjcl.bitArray.P(b,d,c|0,a.slice(0,a.length-1))},bitLength:function(a){var b=a.length;
+if(b===0)return 0;return(b-1)*32+sjcl.bitArray.getPartial(a[b-1])},clamp:function(a,b){if(a.length*32<b)return a;a=a.slice(0,Math.ceil(b/32));var c=a.length;b&=31;if(c>0&&b)a[c-1]=sjcl.bitArray.partial(b,a[c-1]&2147483648>>b-1,1);return a},partial:function(a,b,c){if(a===32)return b;return(c?b|0:b<<32-a)+a*0x10000000000},getPartial:function(a){return Math.round(a/0x10000000000)||32},equal:function(a,b){if(sjcl.bitArray.bitLength(a)!==sjcl.bitArray.bitLength(b))return false;var c=0,d;for(d=0;d<a.length;d++)c|=
+a[d]^b[d];return c===0},P:function(a,b,c,d){var e;e=0;if(d===undefined)d=[];for(;b>=32;b-=32){d.push(c);c=0}if(b===0)return d.concat(a);for(e=0;e<a.length;e++){d.push(c|a[e]>>>b);c=a[e]<<32-b}e=a.length?a[a.length-1]:0;a=sjcl.bitArray.getPartial(e);d.push(sjcl.bitArray.partial(b+a&31,b+a>32?c:d.pop(),1));return d},k:function(a,b){return[a[0]^b[0],a[1]^b[1],a[2]^b[2],a[3]^b[3]]}};
+sjcl.codec.utf8String={fromBits:function(a){var b="",c=sjcl.bitArray.bitLength(a),d,e;for(d=0;d<c/8;d++){if((d&3)===0)e=a[d/4];b+=String.fromCharCode(e>>>24);e<<=8}return decodeURIComponent(escape(b))},toBits:function(a){a=unescape(encodeURIComponent(a));var b=[],c,d=0;for(c=0;c<a.length;c++){d=d<<8|a.charCodeAt(c);if((c&3)===3){b.push(d);d=0}}c&3&&b.push(sjcl.bitArray.partial(8*(c&3),d));return b}};
+sjcl.codec.hex={fromBits:function(a){var b="",c;for(c=0;c<a.length;c++)b+=((a[c]|0)+0xf00000000000).toString(16).substr(4);return b.substr(0,sjcl.bitArray.bitLength(a)/4)},toBits:function(a){var b,c=[],d;a=a.replace(/\s|0x/g,"");d=a.length;a+="00000000";for(b=0;b<a.length;b+=8)c.push(parseInt(a.substr(b,8),16)^0);return sjcl.bitArray.clamp(c,d*4)}};
+sjcl.codec.base64={D:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",fromBits:function(a,b,c){var d="",e=0,f=sjcl.codec.base64.D,g=0,h=sjcl.bitArray.bitLength(a);if(c)f=f.substr(0,62)+"-_";for(c=0;d.length*6<h;){d+=f.charAt((g^a[c]>>>e)>>>26);if(e<6){g=a[c]<<6-e;e+=26;c++}else{g<<=6;e-=6}}for(;d.length&3&&!b;)d+="=";return d},toBits:function(a,b){a=a.replace(/\s|=/g,"");var c=[],d=0,e=sjcl.codec.base64.D,f=0,g;if(b)e=e.substr(0,62)+"-_";for(b=0;b<a.length;b++){g=e.indexOf(a.charAt(b));
+if(g<0)throw new sjcl.exception.invalid("this isn't base64!");if(d>26){d-=26;c.push(f^g>>>d);f=g<<32-d}else{d+=6;f^=g<<32-d}}d&56&&c.push(sjcl.bitArray.partial(d&56,f,1));return c}};sjcl.codec.base64url={fromBits:function(a){return sjcl.codec.base64.fromBits(a,1,1)},toBits:function(a){return sjcl.codec.base64.toBits(a,1)}};sjcl.hash.sha256=function(a){this.a[0]||this.w();if(a){this.n=a.n.slice(0);this.i=a.i.slice(0);this.e=a.e}else this.reset()};sjcl.hash.sha256.hash=function(a){return(new sjcl.hash.sha256).update(a).finalize()};
+sjcl.hash.sha256.prototype={blockSize:512,reset:function(){this.n=this.N.slice(0);this.i=[];this.e=0;return this},update:function(a){if(typeof a==="string")a=sjcl.codec.utf8String.toBits(a);var b,c=this.i=sjcl.bitArray.concat(this.i,a);b=this.e;a=this.e=b+sjcl.bitArray.bitLength(a);for(b=512+b&-512;b<=a;b+=512)this.C(c.splice(0,16));return this},finalize:function(){var a,b=this.i,c=this.n;b=sjcl.bitArray.concat(b,[sjcl.bitArray.partial(1,1)]);for(a=b.length+2;a&15;a++)b.push(0);b.push(Math.floor(this.e/
+4294967296));for(b.push(this.e|0);b.length;)this.C(b.splice(0,16));this.reset();return c},N:[],a:[],w:function(){function a(e){return(e-Math.floor(e))*0x100000000|0}var b=0,c=2,d;a:for(;b<64;c++){for(d=2;d*d<=c;d++)if(c%d===0)continue a;if(b<8)this.N[b]=a(Math.pow(c,0.5));this.a[b]=a(Math.pow(c,1/3));b++}},C:function(a){var b,c,d=a.slice(0),e=this.n,f=this.a,g=e[0],h=e[1],i=e[2],k=e[3],j=e[4],l=e[5],m=e[6],n=e[7];for(a=0;a<64;a++){if(a<16)b=d[a];else{b=d[a+1&15];c=d[a+14&15];b=d[a&15]=(b>>>7^b>>>18^
+b>>>3^b<<25^b<<14)+(c>>>17^c>>>19^c>>>10^c<<15^c<<13)+d[a&15]+d[a+9&15]|0}b=b+n+(j>>>6^j>>>11^j>>>25^j<<26^j<<21^j<<7)+(m^j&(l^m))+f[a];n=m;m=l;l=j;j=k+b|0;k=i;i=h;h=g;g=b+(h&i^k&(h^i))+(h>>>2^h>>>13^h>>>22^h<<30^h<<19^h<<10)|0}e[0]=e[0]+g|0;e[1]=e[1]+h|0;e[2]=e[2]+i|0;e[3]=e[3]+k|0;e[4]=e[4]+j|0;e[5]=e[5]+l|0;e[6]=e[6]+m|0;e[7]=e[7]+n|0}};
+sjcl.mode.ccm={name:"ccm",encrypt:function(a,b,c,d,e){var f,g=b.slice(0),h=sjcl.bitArray,i=h.bitLength(c)/8,k=h.bitLength(g)/8;e=e||64;d=d||[];if(i<7)throw new sjcl.exception.invalid("ccm: iv must be at least 7 bytes");for(f=2;f<4&&k>>>8*f;f++);if(f<15-i)f=15-i;c=h.clamp(c,8*(15-f));b=sjcl.mode.ccm.G(a,b,c,d,e,f);g=sjcl.mode.ccm.I(a,g,c,b,e,f);return h.concat(g.data,g.tag)},decrypt:function(a,b,c,d,e){e=e||64;d=d||[];var f=sjcl.bitArray,g=f.bitLength(c)/8,h=f.bitLength(b),i=f.clamp(b,h-e),k=f.bitSlice(b,
+h-e);h=(h-e)/8;if(g<7)throw new sjcl.exception.invalid("ccm: iv must be at least 7 bytes");for(b=2;b<4&&h>>>8*b;b++);if(b<15-g)b=15-g;c=f.clamp(c,8*(15-b));i=sjcl.mode.ccm.I(a,i,c,k,e,b);a=sjcl.mode.ccm.G(a,i.data,c,d,e,b);if(!f.equal(i.tag,a))throw new sjcl.exception.corrupt("ccm: tag doesn't match");return i.data},G:function(a,b,c,d,e,f){var g=[],h=sjcl.bitArray,i=h.k;e/=8;if(e%2||e<4||e>16)throw new sjcl.exception.invalid("ccm: invalid tag length");if(d.length>0xffffffff||b.length>0xffffffff)throw new sjcl.exception.bug("ccm: can't deal with 4GiB or more data");
+f=[h.partial(8,(d.length?64:0)|e-2<<2|f-1)];f=h.concat(f,c);f[3]|=h.bitLength(b)/8;f=a.encrypt(f);if(d.length){c=h.bitLength(d)/8;if(c<=65279)g=[h.partial(16,c)];else if(c<=0xffffffff)g=h.concat([h.partial(16,65534)],[c]);g=h.concat(g,d);for(d=0;d<g.length;d+=4)f=a.encrypt(i(f,g.slice(d,d+4).concat([0,0,0])))}for(d=0;d<b.length;d+=4)f=a.encrypt(i(f,b.slice(d,d+4).concat([0,0,0])));return h.clamp(f,e*8)},I:function(a,b,c,d,e,f){var g,h=sjcl.bitArray;g=h.k;var i=b.length,k=h.bitLength(b);c=h.concat([h.partial(8,
+f-1)],c).concat([0,0,0]).slice(0,4);d=h.bitSlice(g(d,a.encrypt(c)),0,e);if(!i)return{tag:d,data:[]};for(g=0;g<i;g+=4){c[3]++;e=a.encrypt(c);b[g]^=e[0];b[g+1]^=e[1];b[g+2]^=e[2];b[g+3]^=e[3]}return{tag:d,data:h.clamp(b,k)}}};
+sjcl.mode.ocb2={name:"ocb2",encrypt:function(a,b,c,d,e,f){if(sjcl.bitArray.bitLength(c)!==128)throw new sjcl.exception.invalid("ocb iv must be 128 bits");var g,h=sjcl.mode.ocb2.A,i=sjcl.bitArray,k=i.k,j=[0,0,0,0];c=h(a.encrypt(c));var l,m=[];d=d||[];e=e||64;for(g=0;g+4<b.length;g+=4){l=b.slice(g,g+4);j=k(j,l);m=m.concat(k(c,a.encrypt(k(c,l))));c=h(c)}l=b.slice(g);b=i.bitLength(l);g=a.encrypt(k(c,[0,0,0,b]));l=i.clamp(k(l.concat([0,0,0]),g),b);j=k(j,k(l.concat([0,0,0]),g));j=a.encrypt(k(j,k(c,h(c))));
+if(d.length)j=k(j,f?d:sjcl.mode.ocb2.pmac(a,d));return m.concat(i.concat(l,i.clamp(j,e)))},decrypt:function(a,b,c,d,e,f){if(sjcl.bitArray.bitLength(c)!==128)throw new sjcl.exception.invalid("ocb iv must be 128 bits");e=e||64;var g=sjcl.mode.ocb2.A,h=sjcl.bitArray,i=h.k,k=[0,0,0,0],j=g(a.encrypt(c)),l,m,n=sjcl.bitArray.bitLength(b)-e,o=[];d=d||[];for(c=0;c+4<n/32;c+=4){l=i(j,a.decrypt(i(j,b.slice(c,c+4))));k=i(k,l);o=o.concat(l);j=g(j)}m=n-c*32;l=a.encrypt(i(j,[0,0,0,m]));l=i(l,h.clamp(b.slice(c),
+m).concat([0,0,0]));k=i(k,l);k=a.encrypt(i(k,i(j,g(j))));if(d.length)k=i(k,f?d:sjcl.mode.ocb2.pmac(a,d));if(!h.equal(h.clamp(k,e),h.bitSlice(b,n)))throw new sjcl.exception.corrupt("ocb: tag doesn't match");return o.concat(h.clamp(l,m))},pmac:function(a,b){var c,d=sjcl.mode.ocb2.A,e=sjcl.bitArray,f=e.k,g=[0,0,0,0],h=a.encrypt([0,0,0,0]);h=f(h,d(d(h)));for(c=0;c+4<b.length;c+=4){h=d(h);g=f(g,a.encrypt(f(h,b.slice(c,c+4))))}b=b.slice(c);if(e.bitLength(b)<128){h=f(h,d(h));b=e.concat(b,[2147483648|0,0,
+0,0])}g=f(g,b);return a.encrypt(f(d(f(h,d(h))),g))},A:function(a){return[a[0]<<1^a[1]>>>31,a[1]<<1^a[2]>>>31,a[2]<<1^a[3]>>>31,a[3]<<1^(a[0]>>>31)*135]}};sjcl.misc.hmac=function(a,b){this.M=b=b||sjcl.hash.sha256;var c=[[],[]],d=b.prototype.blockSize/32;this.l=[new b,new b];if(a.length>d)a=b.hash(a);for(b=0;b<d;b++){c[0][b]=a[b]^909522486;c[1][b]=a[b]^1549556828}this.l[0].update(c[0]);this.l[1].update(c[1])};
+sjcl.misc.hmac.prototype.encrypt=sjcl.misc.hmac.prototype.mac=function(a,b){a=(new this.M(this.l[0])).update(a,b).finalize();return(new this.M(this.l[1])).update(a).finalize()};
+sjcl.misc.pbkdf2=function(a,b,c,d,e){c=c||1E3;if(d<0||c<0)throw sjcl.exception.invalid("invalid params to pbkdf2");if(typeof a==="string")a=sjcl.codec.utf8String.toBits(a);e=e||sjcl.misc.hmac;a=new e(a);var f,g,h,i,k=[],j=sjcl.bitArray;for(i=1;32*k.length<(d||1);i++){e=f=a.encrypt(j.concat(b,[i]));for(g=1;g<c;g++){f=a.encrypt(f);for(h=0;h<f.length;h++)e[h]^=f[h]}k=k.concat(e)}if(d)k=j.clamp(k,d);return k};
+sjcl.random={randomWords:function(a,b){var c=[];b=this.isReady(b);var d;if(b===0)throw new sjcl.exception.notReady("generator isn't seeded");else b&2&&this.U(!(b&1));for(b=0;b<a;b+=4){(b+1)%0x10000===0&&this.L();d=this.u();c.push(d[0],d[1],d[2],d[3])}this.L();return c.slice(0,a)},setDefaultParanoia:function(a){this.t=a},addEntropy:function(a,b,c){c=c||"user";var d,e,f=(new Date).valueOf(),g=this.q[c],h=this.isReady();d=this.F[c];if(d===undefined)d=this.F[c]=this.R++;if(g===undefined)g=this.q[c]=0;this.q[c]=
+(this.q[c]+1)%this.b.length;switch(typeof a){case "number":break;case "object":if(b===undefined)for(c=b=0;c<a.length;c++)for(e=a[c];e>0;){b++;e>>>=1}this.b[g].update([d,this.J++,2,b,f,a.length].concat(a));break;case "string":if(b===undefined)b=a.length;this.b[g].update([d,this.J++,3,b,f,a.length]);this.b[g].update(a);break;default:throw new sjcl.exception.bug("random: addEntropy only supports number, array or string");}this.j[g]+=b;this.f+=b;if(h===0){this.isReady()!==0&&this.K("seeded",Math.max(this.g,
+this.f));this.K("progress",this.getProgress())}},isReady:function(a){a=this.B[a!==undefined?a:this.t];return this.g&&this.g>=a?this.j[0]>80&&(new Date).valueOf()>this.O?3:1:this.f>=a?2:0},getProgress:function(a){a=this.B[a?a:this.t];return this.g>=a?1["0"]:this.f>a?1["0"]:this.f/a},startCollectors:function(){if(!this.m){if(window.addEventListener){window.addEventListener("load",this.o,false);window.addEventListener("mousemove",this.p,false)}else if(document.attachEvent){document.attachEvent("onload",
+this.o);document.attachEvent("onmousemove",this.p)}else throw new sjcl.exception.bug("can't attach event");this.m=true}},stopCollectors:function(){if(this.m){if(window.removeEventListener){window.removeEventListener("load",this.o,false);window.removeEventListener("mousemove",this.p,false)}else if(window.detachEvent){window.detachEvent("onload",this.o);window.detachEvent("onmousemove",this.p)}this.m=false}},addEventListener:function(a,b){this.r[a][this.Q++]=b},removeEventListener:function(a,b){var c;
+a=this.r[a];var d=[];for(c in a)a.hasOwnProperty(c)&&a[c]===b&&d.push(c);for(b=0;b<d.length;b++){c=d[b];delete a[c]}},b:[new sjcl.hash.sha256],j:[0],z:0,q:{},J:0,F:{},R:0,g:0,f:0,O:0,a:[0,0,0,0,0,0,0,0],d:[0,0,0,0],s:undefined,t:6,m:false,r:{progress:{},seeded:{}},Q:0,B:[0,48,64,96,128,192,0x100,384,512,768,1024],u:function(){for(var a=0;a<4;a++){this.d[a]=this.d[a]+1|0;if(this.d[a])break}return this.s.encrypt(this.d)},L:function(){this.a=this.u().concat(this.u());this.s=new sjcl.cipher.aes(this.a)},
+T:function(a){this.a=sjcl.hash.sha256.hash(this.a.concat(a));this.s=new sjcl.cipher.aes(this.a);for(a=0;a<4;a++){this.d[a]=this.d[a]+1|0;if(this.d[a])break}},U:function(a){var b=[],c=0,d;this.O=b[0]=(new Date).valueOf()+3E4;for(d=0;d<16;d++)b.push(Math.random()*0x100000000|0);for(d=0;d<this.b.length;d++){b=b.concat(this.b[d].finalize());c+=this.j[d];this.j[d]=0;if(!a&&this.z&1<<d)break}if(this.z>=1<<this.b.length){this.b.push(new sjcl.hash.sha256);this.j.push(0)}this.f-=c;if(c>this.g)this.g=c;this.z++;
+this.T(b)},p:function(a){sjcl.random.addEntropy([a.x||a.clientX||a.offsetX,a.y||a.clientY||a.offsetY],2,"mouse")},o:function(){sjcl.random.addEntropy(new Date,2,"loadtime")},K:function(a,b){var c;a=sjcl.random.r[a];var d=[];for(c in a)a.hasOwnProperty(c)&&d.push(a[c]);for(c=0;c<d.length;c++)d[c](b)}};try{var s=new Uint32Array(32);crypto.getRandomValues(s);sjcl.random.addEntropy(s,1024,"crypto['getRandomValues']")}catch(t){}
+sjcl.json={defaults:{v:1,iter:1E3,ks:128,ts:64,mode:"ccm",adata:"",cipher:"aes"},encrypt:function(a,b,c,d){c=c||{};d=d||{};var e=sjcl.json,f=e.c({iv:sjcl.random.randomWords(4,0)},e.defaults);e.c(f,c);if(typeof f.salt==="string")f.salt=sjcl.codec.base64.toBits(f.salt);if(typeof f.iv==="string")f.iv=sjcl.codec.base64.toBits(f.iv);if(!sjcl.mode[f.mode]||!sjcl.cipher[f.cipher]||typeof a==="string"&&f.iter<=100||f.ts!==64&&f.ts!==96&&f.ts!==128||f.ks!==128&&f.ks!==192&&f.ks!==0x100||f.iv.length<2||f.iv.length>
+4)throw new sjcl.exception.invalid("json encrypt: invalid parameters");if(typeof a==="string"){c=sjcl.misc.cachedPbkdf2(a,f);a=c.key.slice(0,f.ks/32);f.salt=c.salt}if(typeof b==="string")b=sjcl.codec.utf8String.toBits(b);c=new sjcl.cipher[f.cipher](a);e.c(d,f);d.key=a;f.ct=sjcl.mode[f.mode].encrypt(c,b,f.iv,f.adata,f.ts);return e.encode(e.V(f,e.defaults))},decrypt:function(a,b,c,d){c=c||{};d=d||{};var e=sjcl.json;b=e.c(e.c(e.c({},e.defaults),e.decode(b)),c,true);if(typeof b.salt==="string")b.salt=
+sjcl.codec.base64.toBits(b.salt);if(typeof b.iv==="string")b.iv=sjcl.codec.base64.toBits(b.iv);if(!sjcl.mode[b.mode]||!sjcl.cipher[b.cipher]||typeof a==="string"&&b.iter<=100||b.ts!==64&&b.ts!==96&&b.ts!==128||b.ks!==128&&b.ks!==192&&b.ks!==0x100||!b.iv||b.iv.length<2||b.iv.length>4)throw new sjcl.exception.invalid("json decrypt: invalid parameters");if(typeof a==="string"){c=sjcl.misc.cachedPbkdf2(a,b);a=c.key.slice(0,b.ks/32);b.salt=c.salt}c=new sjcl.cipher[b.cipher](a);c=sjcl.mode[b.mode].decrypt(c,
+b.ct,b.iv,b.adata,b.ts);e.c(d,b);d.key=a;return sjcl.codec.utf8String.fromBits(c)},encode:function(a){var b,c="{",d="";for(b in a)if(a.hasOwnProperty(b)){if(!b.match(/^[a-z0-9]+$/i))throw new sjcl.exception.invalid("json encode: invalid property name");c+=d+b+":";d=",";switch(typeof a[b]){case "number":case "boolean":c+=a[b];break;case "string":c+='"'+escape(a[b])+'"';break;case "object":c+='"'+sjcl.codec.base64.fromBits(a[b],1)+'"';break;default:throw new sjcl.exception.bug("json encode: unsupported type");
+}}return c+"}"},decode:function(a){a=a.replace(/\s/g,"");if(!a.match(/^\{.*\}$/))throw new sjcl.exception.invalid("json decode: this isn't json!");a=a.replace(/^\{|\}$/g,"").split(/,/);var b={},c,d;for(c=0;c<a.length;c++){if(!(d=a[c].match(/^([a-z][a-z0-9]*):(?:(\d+)|"([a-z0-9+\/%*_.@=\-]*)")$/i)))throw new sjcl.exception.invalid("json decode: this isn't json!");b[d[1]]=d[2]?parseInt(d[2],10):d[1].match(/^(ct|salt|iv)$/)?sjcl.codec.base64.toBits(d[3]):unescape(d[3])}return b},c:function(a,b,c){if(a===
+undefined)a={};if(b===undefined)return a;var d;for(d in b)if(b.hasOwnProperty(d)){if(c&&a[d]!==undefined&&a[d]!==b[d])throw new sjcl.exception.invalid("required parameter overridden");a[d]=b[d]}return a},V:function(a,b){var c={},d;for(d in a)if(a.hasOwnProperty(d)&&a[d]!==b[d])c[d]=a[d];return c},W:function(a,b){var c={},d;for(d=0;d<b.length;d++)if(a[b[d]]!==undefined)c[b[d]]=a[b[d]];return c}};sjcl.encrypt=sjcl.json.encrypt;sjcl.decrypt=sjcl.json.decrypt;sjcl.misc.S={};
+sjcl.misc.cachedPbkdf2=function(a,b){var c=sjcl.misc.S,d;b=b||{};d=b.iter||1E3;c=c[a]=c[a]||{};d=c[d]=c[d]||{firstSalt:b.salt&&b.salt.length?b.salt.slice(0):sjcl.random.randomWords(2,0)};c=b.salt===undefined?d.firstSalt:b.salt;d[c]=d[c]||sjcl.misc.pbkdf2(a,c,b.iter);return{key:d[c].slice(0),salt:c.slice(0)}};
+})();
View
49 socket.io/custom-presence/app.js
@@ -0,0 +1,49 @@
+(function(){
+
+// -----------------------------------------------------------------------
+// PUBNUB SETUP
+// -----------------------------------------------------------------------
+var my_user_data = { name : "John" };
+var pubnub_setup = {
+ user : my_user_data,
+ channel : 'bootstrap-app',
+ publish_key : 'demo',
+ subscribe_key : 'demo',
+ presence : false
+};
+
+setTimeout( function() {
+ my_user_data.name = "Sam";
+}, 5000 );
+// -----------------------------------------------------------------------
+// CREATE CONNECTION FOR USER EVENTS
+// -----------------------------------------------------------------------
+var socket = io.connect( 'http://pubsub.pubnub.com/events', pubnub_setup );
+
+// -----------------------------------------------------------------------
+// PRESENCE
+// -----------------------------------------------------------------------
+socket.on( 'custom_join', function(user) {
+ console.log(user.data.name, ' -> JOINED!!!');
+} );
+socket.on( 'custom_leave', function(user) {
+ console.log(user.data.name, ' -> LEFT!!!');
+} );
+
+
+// -----------------------------------------------------------------------
+// WAIT FOR A CONNECTION
+// -----------------------------------------------------------------------
+socket.on( 'connect', function() {
+ console.log('connected!!!');
+} );
+
+// -----------------------------------------------------------------------
+// RECEIVE A MESSAGE
+// -----------------------------------------------------------------------
+socket.on( 'message', function(message) {
+ console.log("APP got message : " + message);
+} );
+
+
+})();
View
21 socket.io/custom-presence/index.html
@@ -0,0 +1,21 @@
+<!doctype html>
+<html>
+<head>
+ <!-- Hey, let's be friends! twitter.com/pubnub -->
+ <meta http-equiv=content-type content=text/html;charset=utf-8>
+ <title>PubNub ★ Socket.IO Bootstrap</title>
+ <link
+ href=http://fonts.googleapis.com/css?family=Open+Sans:400,700
+ rel=stylesheet>
+ <link href=styles.css rel=stylesheet>
+</head>
+<body>
+
+<!-- Place Content Here -->
+<div>Hello to Web User!</div>
+<!-- Place Content Here -->
+
+<script src=http://pubnub.s3.amazonaws.com/socket.io.min.js></script>
+<script src=app.js></script>
+</body>
+</html>
View
4 socket.io/custom-presence/styles.css
@@ -0,0 +1,4 @@
+body {
+ font-family: "Open Sans";
+}
+
View
40 socket.io/encryption/app.js
@@ -0,0 +1,40 @@
+(function(){
+
+// -----------------------------------------------------------------------
+// PUBNUB SETUP
+// -----------------------------------------------------------------------
+var pubnub_setup = {
+ channel : 'bootstrap-app',
+ password : '*HLSGHUSEHJFIlT#YUTGKJDHKJ',
+ publish_key : 'demo',
+ subscribe_key : 'demo'
+};
+
+// -----------------------------------------------------------------------
+// CREATE CONNECTION FOR USER EVENTS
+// -----------------------------------------------------------------------
+var socket = io.connect( 'http://pubsub.pubnub.com/events', pubnub_setup );
+
+// -----------------------------------------------------------------------
+// WAIT FOR A CONNECTION
+// -----------------------------------------------------------------------
+socket.on( 'connect', function() {
+
+ // Connected!!!
+ socket.send('SUPER SECRET!!!!!!! EATING BATTERIES');
+
+} );
+
+// -----------------------------------------------------------------------
+// RECEIVE A MESSAGE
+// -----------------------------------------------------------------------
+socket.on( 'message', function(message) {
+
+ // Received a Message!
+ console.log(message);
+ // i0cz1TAv8dWjsu6F
+ // HfhzNsTGrc66OZgEFL4jmjvXC1Zg6J
+
+} );
+
+})();
View
21 socket.io/encryption/index.html
@@ -0,0 +1,21 @@
+<!doctype html>
+<html>
+<head>
+ <!-- Hey, let's be friends! twitter.com/pubnub -->
+ <meta http-equiv=content-type content=text/html;charset=utf-8>
+ <title>PubNub ★ Socket.IO Bootstrap</title>
+ <link
+ href=http://fonts.googleapis.com/css?family=Open+Sans:400,700
+ rel=stylesheet>
+ <link href=styles.css rel=stylesheet>
+</head>
+<body>
+
+<!-- Place Content Here -->
+<div>Hello to Web User!</div>
+<!-- Place Content Here -->
+
+<script src=http://pubnub.s3.amazonaws.com/socket.io.min.js></script>
+<script src=app.js></script>
+</body>
+</html>
View
4 socket.io/encryption/styles.css
@@ -0,0 +1,4 @@
+body {
+ font-family: "Open Sans";
+}
+
View
36 socket.io/hello-world/app.js
@@ -0,0 +1,36 @@
+(function(){
+
+// -----------------------------------------------------------------------
+// PUBNUB SETUP
+// -----------------------------------------------------------------------
+var pubnub_setup = {
+ channel : 'bootstrap-app',
+ publish_key : 'demo',
+ subscribe_key : 'demo'
+};
+
+// -----------------------------------------------------------------------
+// CREATE CONNECTION FOR USER EVENTS
+// -----------------------------------------------------------------------
+var socket = io.connect( 'http://pubsub.pubnub.com/events', pubnub_setup );
+
+// -----------------------------------------------------------------------
+// WAIT FOR A CONNECTION
+// -----------------------------------------------------------------------
+socket.on( 'connect', function() {
+
+ // Connected!!!
+ alert('CONNECTED!!!!!!!');
+
+} );
+
+// -----------------------------------------------------------------------
+// RECEIVE A MESSAGE
+// -----------------------------------------------------------------------
+socket.on( 'message', function(message) {
+
+ // Received a Message!
+
+} );
+
+})();
View
21 socket.io/hello-world/index.html
@@ -0,0 +1,21 @@
+<!doctype html>
+<html>
+<head>
+ <!-- Hey, let's be friends! twitter.com/pubnub -->
+ <meta http-equiv=content-type content=text/html;charset=utf-8>
+ <title>PubNub ★ Socket.IO Bootstrap</title>
+ <link
+ href=http://fonts.googleapis.com/css?family=Open+Sans:400,700
+ rel=stylesheet>
+ <link href=styles.css rel=stylesheet>
+</head>
+<body>
+
+<!-- Place Content Here -->
+<div>Hello to Web User!</div>
+<!-- Place Content Here -->
+
+<script src=http://pubnub.s3.amazonaws.com/socket.io.min.js></script>
+<script src=app.js></script>
+</body>
+</html>
View
4 socket.io/hello-world/styles.css
@@ -0,0 +1,4 @@
+body {
+ font-family: "Open Sans";
+}
+
View
38 socket.io/here_now/app.js
@@ -0,0 +1,38 @@
+(function () {
+
+// -----------------------------------------------------------------------
+// PUBNUB SETUP
+// -----------------------------------------------------------------------
+ var my_user_data = { name:"John" };
+ var pubnub_setup = {
+ user:my_user_data,
+ channel:'bootstrap-app',
+ publish_key:'demo',
+ subscribe_key:'demo',
+ custom_presence:false
+ };
+
+// -----------------------------------------------------------------------
+// CREATE CONNECTION FOR USER EVENTS
+// -----------------------------------------------------------------------
+ var socket = io.connect('http://pubsub.pubnub.com/herenow', pubnub_setup);
+
+
+// -----------------------------------------------------------------------
+// WAIT FOR A CONNECTION, then get here_now data
+// -----------------------------------------------------------------------
+ socket.on('connect', function () {
+ console.log('connected!!!');
+ getHereNow();
+ });
+
+ var getHereNow = function() {
+ socket.here_now(function (response) {
+ console.log(response);
+ });
+ }
+
+ textDiv = document.getElementById('text');
+ textDiv.onclick = getHereNow;
+
+})();
View
25 socket.io/here_now/index.html
@@ -0,0 +1,25 @@
+<!doctype html>
+<html>
+<head>
+ <!-- Hey, let's be friends! twitter.com/pubnub -->
+ <meta http-equiv=content-type content=text/html;charset=utf-8>
+ <title>PubNub ★ Socket.IO Bootstrap</title>
+ <link
+ href=http://fonts.googleapis.com/css?family=Open+Sans:400,700
+ rel=stylesheet>
+ <link href=styles.css rel=stylesheet>
+</head>
+<body>
+
+<!-- Place Content Here -->
+<div id="text" >Click me and check the console log for here now!</div>
+<!-- Place Content Here -->
+
+<script src=../../../javascript/pubnub-3.3.js></script>
+<script src=../crypto.js></script>
+<script src=../socket.io.js></script>
+
+<script src=app.js></script>
+
+</body>
+</html>
View
4 socket.io/here_now/styles.css
@@ -0,0 +1,4 @@
+body {
+ font-family: "Open Sans";
+}
+
View
51 socket.io/history/app.js
@@ -0,0 +1,51 @@
+(function () {
+
+// -----------------------------------------------------------------------
+// PUBNUB SETUP
+// -----------------------------------------------------------------------
+ var my_user_data = { name:"John" };
+ var pubnub_setup = {
+ user:my_user_data,
+ channel:'bootstrap-app',
+ publish_key:'demo',
+ subscribe_key:'demo',
+ custom_presence:false,
+ presence:false
+ };
+
+// -----------------------------------------------------------------------
+// CREATE CONNECTION FOR USER EVENTS
+// -----------------------------------------------------------------------
+ var socket = io.connect('http://pubsub.pubnub.com/history', pubnub_setup);
+
+
+// -----------------------------------------------------------------------
+// WAIT FOR A CONNECTION, then publish and get history
+// -----------------------------------------------------------------------
+
+ socket.on('connect', function () {
+ console.log('connected!!!');
+ seedHistory();
+ });
+
+
+ function seedHistory() {
+
+ for (a = 0; a < 9; a++) {
+ socket.send('test data ' + a, function (message) { console.log("Seeding history data: " + message)} );
+ }
+
+ getHistory(socket);
+ }
+
+ var getHistory = function() {
+ socket.history({'count':10}, function (response) {
+ console.log(response);
+ });
+ }
+
+ textDiv = document.getElementById('text');
+ textDiv.onclick = getHistory;
+
+
+})();
View
25 socket.io/history/index.html
@@ -0,0 +1,25 @@
+<!doctype html>
+<html>
+<head>
+ <!-- Hey, let's be friends! twitter.com/pubnub -->
+ <meta http-equiv=content-type content=text/html;charset=utf-8>
+ <title>PubNub ★ Socket.IO Bootstrap</title>
+ <link
+ href=http://fonts.googleapis.com/css?family=Open+Sans:400,700
+ rel=stylesheet>
+ <link href=styles.css rel=stylesheet>
+</head>
+<body>
+
+<!-- Place Content Here -->
+<div id="text" >Click me and check the console log for history!</div>
+
+<!-- Place Content Here -->
+
+<script src=../../../javascript/pubnub-3.3.js></script>
+<script src=../crypto.js></script>
+<script src=../socket.io.js></script>
+
+<script src=app.js></script>
+</body>
+</html>
View
4 socket.io/history/styles.css
@@ -0,0 +1,4 @@
+body {
+ font-family: "Open Sans";
+}
+
View
35 socket.io/multiplexing/app.js
@@ -0,0 +1,35 @@
+(function(){
+
+// -----------------------------------------------------------------------
+// PUBNUB SETUP
+// -----------------------------------------------------------------------
+var pubnub_setup = {
+ channel : 'bootstrap-app',
+ publish_key : 'demo',
+ subscribe_key : 'demo'
+};
+
+// -----------------------------------------------------------------------
+// CREATE CONNECTION FOR USER EVENTS
+// -----------------------------------------------------------------------
+var socket1 = io.connect( 'http://pubsub.pubnub.com/socket1', pubnub_setup );
+var socket2 = io.connect( 'http://pubsub.pubnub.com/socket2', pubnub_setup );
+var socket3 = io.connect( 'http://pubsub.pubnub.com/socket3', pubnub_setup );
+
+
+socket1.on( 'connect', function() {
+ console.log( 'i connected on socket1' );
+} );
+socket2.on( 'connect', function() {
+ console.log( 'i connected on socket2' );
+} );
+socket3.on( 'connect', function() {
+ socket2.send('HELLO!O!O!!');
+ console.log( 'i connected on socket3' );
+} );
+
+socket2.on( 'message', function(message) {
+ console.log('socket2:', message);
+} );
+
+})();
View
21 socket.io/multiplexing/index.html
@@ -0,0 +1,21 @@
+<!doctype html>
+<html>
+<head>
+ <!-- Hey, let's be friends! twitter.com/pubnub -->
+ <meta http-equiv=content-type content=text/html;charset=utf-8>
+ <title>PubNub ★ Socket.IO Bootstrap</title>
+ <link
+ href=http://fonts.googleapis.com/css?family=Open+Sans:400,700
+ rel=stylesheet>
+ <link href=styles.css rel=stylesheet>
+</head>
+<body>
+
+<!-- Place Content Here -->
+<div>Hello to Web User!</div>
+<!-- Place Content Here -->
+
+<script src=http://pubnub.s3.amazonaws.com/socket.io.min.js></script>
+<script src=app.js></script>
+</body>
+</html>
View
4 socket.io/multiplexing/styles.css
@@ -0,0 +1,4 @@
+body {
+ font-family: "Open Sans";
+}
+
View
29 socket.io/non-socket-io-communication/README.md
@@ -0,0 +1,29 @@
+# Sending Events from the Dev Console
+
+It's simple to send/receive messages from the Dev Console using Socket.IO
+by following these instructions.
+You must simply follow the format of the message and issue a Publish Message
+using your `Channel Name` and `Namespace` used in your Socket.IO app.
+
+# Sending Events from a Server or Dev Console
+
+This example shows you how to send events to your Socket.IO clients
+using other PubNub libraries. We are using the simple syntax of `Python`
+here for the example:
+
+```python
+from PubNub import PubNub
+
+## Create a PubNub Object
+pubnub = PubNub( 'demo', 'demo', None, False )
+
+## Publish To Socket.IO
+pubnub.publish({
+ 'channel' : 'my_pn_channel',
+ 'message' : {
+ "name" : "message", ## Event Name
+ "ns" : "example-ns-my_pn_channel", ## Namespace
+ "data" : { "my" : "data" } ## Your Message
+ }
+})
+
View
30 socket.io/non-socket-io-communication/app.js
@@ -0,0 +1,30 @@
+(function(){
+
+// -----------------------------------------------------------------------
+// PUBNUB SETUP
+// -----------------------------------------------------------------------
+var pubnub_setup = {
+ channel : 'my_pn_channel',
+ publish_key : 'demo',
+ subscribe_key : 'demo'
+};
+
+// -----------------------------------------------------------------------
+// CREATE CONNECTION FOR USER EVENTS
+// -----------------------------------------------------------------------
+var socket = io.connect(
+ 'http://pubsub.pubnub.com/example-ns',
+ pubnub_setup
+);
+
+// -----------------------------------------------------------------------
+// RECEIVE A MESSAGE
+// -----------------------------------------------------------------------
+socket.on( 'message', function(message) {
+
+ // Received a Message!
+ alert(JSON.stringify(message));
+
+} );
+
+})();
View
BIN  socket.io/non-socket-io-communication/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
48 socket.io/non-socket-io-communication/index.html
@@ -0,0 +1,48 @@
+<!doctype html>
+<html>
+<head>
+ <!-- Hey, let's be friends! twitter.com/pubnub -->
+ <meta http-equiv=content-type content=text/html;charset=utf-8>
+
+ <meta name=viewport content=width=device-width>
+ <meta name=viewport content=initial-scale=1.0>
+ <meta name=viewport content=user-scalable=no>
+
+ <meta name=apple-mobile-web-app-capable content=yes>
+ <meta name=apple-mobile-web-app-status-bar-style content=black>
+
+ <link rel=apple-touch-icon href=icon.png>
+ <link rel=apple-touch-startup-image href=startup.png>
+
+ <title>PubNub ★ Non-Socket.IO Communication</title>
+
+ <link
+ href=http://fonts.googleapis.com/css?family=Open+Sans:400,700
+ rel=stylesheet>
+ <link href=styles.css rel=stylesheet>
+</head>
+<body>
+
+<h1>PubNub ★ Non-Socket.IO Communication</h1>
+<div>
+ Now that you have this page open,
+ click to go to the
+ <a href=http://www.pubnub.com/console?channel=my_pn_channel&sub=demo&pub=demo>PubNub Dev Console</a>.
+</div>
+<div>
+ Once on this page, put in this JSON message
+ into the message textarea field:
+ <code><pre style=background:#eeeee2>
+
+ { "name" : "message",
+ "ns" : "example-ns-my_pn_channel",
+ "data" : {"my":"data"} }
+ </pre></code>
+</div>
+After you copy/pasted that JSON text, simply click the [Send] button.
+
+<script>scrollTo(0,1);</script>
+<script src=http://pubnub.s3.amazonaws.com/socket.io.min.js></script>
+<script src=app.js></script>
+</body>
+</html>
View
BIN  socket.io/non-socket-io-communication/startup.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
4 socket.io/non-socket-io-communication/styles.css
@@ -0,0 +1,4 @@
+body {
+ font-family: "Open Sans";
+}
+
View
38 socket.io/presence/app.js
@@ -0,0 +1,38 @@
+(function(){
+
+// -----------------------------------------------------------------------
+// PUBNUB SETUP
+// -----------------------------------------------------------------------
+var my_user_data = { name : "John" };
+var pubnub_setup = {
+ user : my_user_data,
+ channel : 'bootstrap-app',
+ publish_key : 'demo',
+ subscribe_key : 'demo',
+ custom_presence: false
+};
+
+// -----------------------------------------------------------------------
+// CREATE CONNECTION FOR USER EVENTS
+// -----------------------------------------------------------------------
+var socket = io.connect( 'http://pubsub.pubnub.com/presence', pubnub_setup );
+
+// -----------------------------------------------------------------------
+// PRESENCE
+// -----------------------------------------------------------------------
+socket.on( 'join', function(uuid) {
+ console.log(uuid, ' -> JOINED!!!');
+} );
+socket.on( 'leave', function(uuid) {
+ console.log(uuid, ' -> LEFT!!!');
+} );
+
+
+// -----------------------------------------------------------------------
+// WAIT FOR A CONNECTION
+// -----------------------------------------------------------------------
+socket.on( 'connect', function() {
+ console.log('connected!!!');
+} );
+
+})();
View
23 socket.io/presence/index.html
@@ -0,0 +1,23 @@
+<!doctype html>
+<html>
+<head>
+ <!-- Hey, let's be friends! twitter.com/pubnub -->
+ <meta http-equiv=content-type content=text/html;charset=utf-8>
+ <title>PubNub ★ Socket.IO Bootstrap</title>
+ <link
+ href=http://fonts.googleapis.com/css?family=Open+Sans:400,700
+ rel=stylesheet>
+ <link href=styles.css rel=stylesheet>
+</head>
+<body>
+
+<!-- Place Content Here -->
+<div>Hello to Web User!</div>
+<!-- Place Content Here -->
+
+<script src=../../../javascript/pubnub-3.3.js></script>
+<script src=../crypto.js></script>
+<script src=../socket.io.js></script>
+<script src=app.js></script>
+</body>
+</html>
View
4 socket.io/presence/styles.css
@@ -0,0 +1,4 @@
+body {
+ font-family: "Open Sans";
+}
+
View
60 socket.io/public-private-communication/public-private-communication.html
@@ -0,0 +1,60 @@
+<!doctype html>
+<html>
+<head>
+ <title>PubNub Socket.IO Unit Test</title>
+ <link
+ rel=stylesheet
+ href=http://twitter.github.com/bootstrap/1.4.0/bootstrap.min.css
+ >
+ <style type=text/css>
+ #stop-test,
+ #finished-fail,
+ #finished-success,
+ {display:none}
+ </style>
+</head>
+<body><div class=container>
+
+<!-- NOTICE / TITLE -->
+<div class="alert-message warning">
+ <a class="close" href="#">&#215;</a>
+ <p>
+ <strong>PubNub Unit Tests</strong>
+ for Socket.IO on Mobile and Desktop Web Browser
+ </p>
+</div>
+
+<!-- BUTTON PANNEL -->
+<div class=well>
+ <button id=start-test class='btn info'>Start Test</button>
+ <button id=stop-test class='btn danger'>STOP</button>
+ <span id=finished-success class='label success'>100% Successful</span>
+ <span id=finished-fail class='label important'>Finished With Errors</span>
+ <span
+ id=test-status
+ class=label
+ template='Result: {pass}/{fail} (pass/fail) - Total: {total}'
+ >...</span>
+</div>
+
+<!-- OUTPUT -->
+<table id=unit-test-out class="zebra-striped">
+ <tr><th><span class=label>Pass/Fail</span><th>Test Ready
+</table>
+
+<!-- TEMPLATES -->
+<script type=text/template id=test_template>
+ <td><span class="label {result}">{display}</span></td>
+ <td>{message}</td>
+</script>
+
+<div id=pubnub></div>
+<!--
+<script src=http://pubnub.s3.amazonaws.com/pubnub-3.1.js></script>
+<script src=../crypto.js></script>
+<script src=../socket.io.js></script>
+-->
+<script src=../socket.io.min.js></script>
+<script src=public-private-communication.js></script>
+</div></body>
+</html>
View
142 socket.io/public-private-communication/public-private-communication.js
@@ -0,0 +1,142 @@
+(function(){
+
+ function test( t, msg ) {
+ if (!test.run) return;
+
+ var entry = p.create('tr');
+
+ entry.innerHTML = p.supplant( test_tpl, {
+ result : t ? 'success' : 'important',
+ display : t ? 'pass' : 'fail',
+ message : msg
+ } );
+
+ t ? test.pass++ : test.fail++;
+ test.done++;
+
+ out.insertBefore( entry, out.firstChild );
+ console.log( t, msg );
+
+ status_area.innerHTML = p.supplant( status_tpl, {
+ pass : test.pass+'',
+ fail : test.fail+'',
+ total : test.done+''
+ } );
+
+ if (test.done === test.plan) {
+ stop_test();
+
+ if (test.fail) return p.css(
+ p.$('finished-fail'),
+ { display : 'inline-block' }
+ );
+
+ p.css( p.$('finished-success'), { display : 'inline-block' } );
+ }
+ }
+
+ var p = PUBNUB
+ , channel = 'pn-javascript-unit-test'
+ , out = p.$('unit-test-out')
+ , test_tpl = p.$('test_template').innerHTML
+ , start_button = p.$('start-test')
+ , stop_button = p.$('stop-test')
+ , status_area = p.$('test-status')
+ , status_tpl = p.attr( status_area, 'template' );
+
+
+ /* ======================================================================
+ Stop Test
+ ====================================================================== */
+ p.bind( 'mousedown,touchstart', stop_button, stop_test );
+ function stop_test() {
+ p.css( start_button, { display : 'inline-block' } );
+ p.css( stop_button, { display : 'none' } );
+ test.run = 0;
+ }
+
+ /* ======================================================================
+ Start Test
+ ====================================================================== */
+ p.bind( 'mousedown,touchstart', start_button, start_test );
+
+ function start_test() {
+ test.plan = 8; // # of tests
+ test.pass = 0; // 0 passes so far
+ test.fail = 0; // 0 failes so far
+ test.done = 0; // 0 tests done so far
+ test.run = 1; // continue running?
+
+ p.css( stop_button, { display : 'inline-block' } );
+ p.css( start_button, { display : 'none' } );
+ p.css( p.$('finished-fail'), { display : 'none' } );
+ p.css( p.$('finished-success'), { display : 'none' } );
+
+ test( 1, 'Ready to Test' );
+
+ test( 'PUBNUB' in window, 'PubNub Lib Exists' );
+ test( 'io' in window, 'Socket.IO Lib Exists' );
+ test( 'sjcl' in window, 'Stanford Crypto Lib Exists' );
+
+ var my_user_data = { name : 'John' };
+ var public_setup = {
+ user : my_user_data,
+ channel : 'public-channel',
+ publish_key : 'demo',
+ subscribe_key : 'demo',
+ presence : false
+ };
+
+ var private_setup = {
+ user : my_user_data,
+ channel : 'jIyNTc3X2JIV1U2M2I2ZkR0NzkK',
+ publish_key : 'demo',
+ subscribe_key : 'demo',
+ presence : false
+ };
+
+ var private_socket = io.connect(
+ 'http://pubsub.pubnub.com/private',
+ private_setup
+ );
+ var public_socket = io.connect(
+ 'http://pubsub.pubnub.com/public',
+ public_setup
+ );
+
+ var public2 = io.connect(
+ 'http://pubsub.pubnub.com/public2',
+ public_setup
+ );
+
+ var public3 = io.connect(
+ 'http://pubsub.pubnub.com/public3',
+ public_setup
+ );
+ var public4 = io.connect(
+ 'http://pubsub.pubnub.com/public4',
+ public_setup
+ );
+
+ public_socket.on( 'connect', function() {
+ test( 1, 'Public Socket Connected (SOCKET 1)' );
+ public_socket.send('public');
+ } );
+
+ private_socket.on( 'connect', function() {
+ test( 1, 'Private Socket Connected (SOCKET 2)' );
+ private_socket.send('private');
+ } );
+
+ public_socket.on( 'message', function(message) {
+ test( message == 'public', 'Public Message Received (SOCKET 1)' );
+ } );
+
+ private_socket.on( 'message', function(message) {
+ test( message == 'private', 'Private Message Received (SOCKET 2)' );
+ } );
+
+ }
+ start_test();
+
+})();
View
92 socket.io/simple-button/app.js
@@ -0,0 +1,92 @@
+(function(){
+
+// -----------------------------------------------------------------------
+// PAGE ELEMENTS
+// -----------------------------------------------------------------------
+var p = PUBNUB
+, button = p.$('button')
+, stages = p.$('stages')
+, notify = p.$('notify')
+, indicators = stages.getElementsByTagName('div')
+, light = p.$('button-light');
+
+// -----------------------------------------------------------------------
+// PUBNUB SETUP
+// -----------------------------------------------------------------------
+var pubnub_setup = {
+ channel : 'sample-button-app',
+ publish_key : 'demo',
+ subscribe_key : 'demo'
+};
+
+// -----------------------------------------------------------------------
+// CREATE CONNECTION FOR USER EVENTS
+// -----------------------------------------------------------------------
+var user_event = io.connect( 'http://pubsub.pubnub.com/events', pubnub_setup );
+
+// -----------------------------------------------------------------------
+// WAIT FOR A CONNECTION
+// -----------------------------------------------------------------------
+user_event.on( 'connect', function() {
+ advance();
+ button.removeAttribute('disabled');
+ button.innerHTML = 'Touch';
+} );
+
+// -----------------------------------------------------------------------
+// LISTEN FOR A USER EVENT
+// -----------------------------------------------------------------------
+user_event.on( 'buttontouch', function(color) {
+
+ notify.play();
+ p.css( light, { background : color } );
+
+ clearTimeout(button.timer);
+ button.timer = setTimeout( function() {
+ p.css( light, { background : '#fff' } );
+ }, 200 );
+
+} );
+
+// -----------------------------------------------------------------------
+// BUTTON CLICK
+// -----------------------------------------------------------------------
+p.bind( 'mousedown,touchstart', button, function() {
+ user_event.emit( 'buttontouch', rnd_color() );
+} );
+
+// -----------------------------------------------------------------------
+// RANDOM COLOR
+// -----------------------------------------------------------------------
+function rnd_hex() { return Math.ceil(Math.random()*9) }
+function rnd_color() {
+ return '#' + p.map(
+ Array(3).join().split(','), rnd_hex
+ ).join('');
+}
+
+// -----------------------------------------------------------------------
+// ADVANCE STAGE INDICATORS
+// -----------------------------------------------------------------------
+indicators.stage = 0;
+function advance() {
+ var stage = indicators.stage++;
+ setTimeout( function() {
+ p.css( indicators[stage], { background : '#4a3' } );
+ }, 400 * (stage === 2 ? (function(){
+ p.css( stages, { background : '#7d6' } );
+ setTimeout( function() {
+ p.css( stages, { background : '#eeeee3' } );
+ }, 300 );
+ return 0;
+ })() : stage) );
+}
+
+// -----------------------------------------------------------------------
+// BEGIN INDICATOR LIGHT ADVANCEMENTS
+// -----------------------------------------------------------------------
+advance();
+p.bind( 'load', window, advance );
+
+
+})();
View
BIN  socket.io/simple-button/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
49 socket.io/simple-button/index.html
@@ -0,0 +1,49 @@
+<!doctype html>
+<html>
+<head>
+ <!-- Hey, let's be friends! twitter.com/pubnub -->
+ <meta http-equiv=content-type content=text/html;charset=utf-8>
+
+ <meta name=viewport content=width=device-width>
+ <meta name=viewport content=initial-scale=1.0>
+ <meta name=viewport content=user-scalable=no>
+
+ <meta name=apple-mobile-web-app-capable content=yes>
+ <meta name=apple-mobile-web-app-status-bar-style content=black>
+
+ <link rel=apple-touch-icon href=icon.png>
+ <link rel=apple-touch-startup-image href=startup.png>
+
+ <title>PubNub ★ Socket.IO Bootstrap</title>
+
+ <link
+ href=http://fonts.googleapis.com/css?family=Open+Sans:400,700
+ rel=stylesheet>
+ <link href=styles.css rel=stylesheet>
+</head>
+<body>
+
+<!-- STAGE OF CONNECTIVITY -->
+<div id=stages>
+ <div class=indicator></div>
+ <div class=indicator></div>
+ <div class=indicator></div>
+</div>
+<div id=stages-shine></div>
+
+<!-- BUTTON PRESS INDICATOR -->
+<div id=button-light>Touch Detected</div>
+
+<!-- SIMPLE BUTTON -->
+<button id=button>Connecting...</div>
+
+<audio id="notify" preload=auto autobuffer>
+ <source src=notify.ogg>
+ <source src=notify.mp3>
+</audio>
+
+<script>scrollTo(0,1);</script>
+<script src=http://pubnub.s3.amazonaws.com/socket.io.min.js></script>
+<script src=app.js></script>
+</body>
+</html>
View
BIN  socket.io/simple-button/notify.mp3
Binary file not shown
View
BIN  socket.io/simple-button/notify.ogg
Binary file not shown
View
BIN  socket.io/simple-button/startup.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
146 socket.io/simple-button/styles.css
@@ -0,0 +1,146 @@
+::-moz-selection { background-color: rgba(0,0,0,0); }
+::selection { background-color: rgba(0,0,0,0); }
+
+body {
+ font-family: "Open Sans";
+ -webkit-tap-highlight-color: rgba(0,0,0,0);
+}
+
+/* STAGES OF CONNECTIVITY */
+#stages, #stages-shine {
+ position: absolute;
+ top: 250px;
+ left: 20px;
+ width: 280px;
+ height: 50px;
+
+ -webkit-transition: background 0.2s;
+ -moz-transition: background 0.2s;
+ -ms-transition: background 0.2s;
+ -o-transition: background 0.2s;
+ transition: background 0.2s;
+
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px;
+
+ background: #eeeee3;
+}
+#stages-shine {
+ height: 25px;
+ opacity: 0.7;
+ background: #fff;
+}
+
+.indicator {
+ display: inline-block;
+ width: 20px;
+ height: 20px;
+
+ margin: 15px 0 0 50px;
+
+ -webkit-transition: background 0.6s;
+ -moz-transition: background 0.6s;
+ -ms-transition: background 0.6s;
+ -o-transition: background 0.6s;
+ transition: background 0.6s;
+
+ background-color: #f00;
+
+ -webkit-border-radius: 99px;
+ -moz-border-radius: 99px;
+ border-radius: 99px;
+}
+
+/* BUTTON LIGHT INDICATOR ON BUTTON PRESS */
+#button-light {
+ position: absolute;
+ top: 30px;
+ left: 30px;
+ width: 260px;
+ height: 70px;
+
+ -webkit-transition: background 0.2s;
+ -moz-transition: background 0.2s;
+ -ms-transition: background 0.2s;
+ -o-transition: background 0.2s;
+ transition: background 0.2s;
+
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px;
+
+ background: #fffffd;
+
+ color: #fffffd;
+
+ font-size: 20px;
+ text-align: center;
+ line-height: 70px;
+}
+
+
+/* VERY NICE BUTTON */
+#button {
+ position: absolute;
+ top: 130px;
+ left: 60px;
+ width: 200px;
+ height: 100px;
+
+ color: #ffffff;
+ font-size: 20px;
+ font-weight: 700;
+ text-align: center;
+ text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);
+
+ cursor: pointer;
+
+ line-height: normal;
+ border: 1px solid #ccc;
+ border-bottom-color: #bbb;
+
+ text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
+ border-color: #0064cd #0064cd #003f81;
+ border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
+
+ -webkit-border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-radius: 4px;
+
+ -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
+ -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
+ box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
+
+ -webkit-transition: 0.1s linear all;
+ -moz-transition: 0.1s linear all;
+ -ms-transition: 0.1s linear all;
+ -o-transition: 0.1s linear all;
+ transition: 0.1s linear all;
+
+ background-image: -webkit-linear-gradient(top, #049cdb, #0064cd);
+ background-color: #0064cd;
+ background-repeat: repeat-x;
+ background-image: -khtml-gradient(linear, left top, left bottom, from(#049cdb), to(#0064cd));
+ background-image: -moz-linear-gradient(top, #049cdb, #0064cd);
+ background-image: -ms-linear-gradient(top, #049cdb, #0064cd);
+ background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #049cdb), color-stop(100%, #0064cd));
+ background-image: -webkit-linear-gradient(top, #049cdb, #0064cd);
+ background-image: -o-linear-gradient(top, #049cdb, #0064cd);
+ background-image: linear-gradient(top, #049cdb, #0064cd);
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#049cdb', endColorstr='#0064cd', GradientType=0);
+}
+#button:hover {
+ background-position: 0 -15px;
+ color: #333;
+ text-decoration: none;
+}
+#button:focus {
+ outline: 1px dotted #666;
+}
+#button-light, #stages, .indicator, #button:active {
+ -webkit-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.25), 0 1px 2px rgba(0, 0, 0, 0.05);
+ -moz-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.25), 0 1px 2px rgba(0, 0, 0, 0.05);
+ box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.25), 0 1px 2px rgba(0, 0, 0, 0.05);
+}
+
View
262 socket.io/socket.io.js
@@ -0,0 +1,262 @@
+(function(){
+
+ // =====================================================================
+ // PubNub Socket.IO
+ // =====================================================================
+ var p = PUBNUB
+ , has_setup = 0
+ , uuid = PUBNUB.db.get('uuid') || p.uuid(function(id){
+ PUBNUB.db.set( 'uuid', uuid = id )
+ })
+ , now = function(){return+new Date}
+ , namespaces = {}
+ , users = {}
+ , io = window.io = {
+ connected : {},
+ connect : function( host, setup ) {
+
+ // PARSE SETUP and HOST
+ var urlbits = (host+'////').split('/')
+ , setup = setup || {}
+ , cuser = setup['user'