From 86b02fe40dd76912151a5f856a3dabbb621e613d Mon Sep 17 00:00:00 2001 From: Will Holcomb Date: Fri, 28 Jun 2013 21:30:49 -0400 Subject: [PATCH 01/12] merging changes accidentally committed in gh-pages --- server.js | 2 +- simpleSignaling.js | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/server.js b/server.js index 0fc1d34..47c2a21 100644 --- a/server.js +++ b/server.js @@ -14,7 +14,7 @@ function requestListener(req, res) res.writeHead(200, {'Content-Type': 'text/html'}); res.write('This is a SimpleSignaling handshake server. You can get a copy '); res.write('of the source code at '); - res.end ('GitHub'); + res.end ('GitHub'); } var server = require('http').createServer(requestListener); diff --git a/simpleSignaling.js b/simpleSignaling.js index 3bcda3c..ef4cc6d 100644 --- a/simpleSignaling.js +++ b/simpleSignaling.js @@ -6,14 +6,16 @@ function SimpleSignaling(configuration) { var self = this; - var room = (configuration.room != undefined) ? configuration.room : 'default room'; + var room = configuration.room || 'default room'; /** * UUID generator */ + // Version 4 UUIDs have the form xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx where x is any hexadecimal digit and y is one of 8, 9, a, or b + // (e.g., f47ac10b-58cc-4372-a567-0e02b2c3d479). var UUIDv4 = function b(a){return a?(a^Math.random()*16>>a/4).toString(16):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,b)}; - var uid = (configuration.uid != undefined) ? configuration.uid : UUIDv4(); + var uid = configuration.uid || UUIDv4(); var websocket = new WebSocket(configuration.ws_uri); websocket.onopen = function() From 77287e2ec599f441a415c165b612337c7da00472 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Sat, 29 Jun 2013 01:33:58 +0000 Subject: [PATCH 02/12] adding log message with listening port --- server.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server.js b/server.js index 0fc1d34..7c2a1b9 100644 --- a/server.js +++ b/server.js @@ -8,6 +8,8 @@ var options = {key: fs.readFileSync('certs/privatekey.pem').toString(), // Get AppFog port, or set 8080 as default one (dotCloud mandatory) var port = process.env.VMC_APP_PORT || 8080; +console.log( "Starting server on port " + port ) + // HTTP server function requestListener(req, res) { From 0c0c153ee4236c4daf1b92cf1483d22bcfc3ffe4 Mon Sep 17 00:00:00 2001 From: Will Holcomb Date: Fri, 28 Jun 2013 23:16:23 -0400 Subject: [PATCH 03/12] adding api reference --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 82136cc..99fbeb9 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,24 @@ There's also a (public) SSL enabled backend server that you can use at wss://simplesignaling-piranna.dotcloud.com. Just for testing purposes please, the bandwidth is high, but not infinite... :-) +## API + +var server = new SimpleSignaling( { + // The SimpleSignaling server + ws_uri: 'ws://ec2-54-242-188-68.compute-1.amazonaws.com:8080', + room: 'broadcast-test', // Optional, not really used in this example + uid: 'user identifier' // Optional, a [UUIDv4](//en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_.28random.29) will be generated +} ) + +server.onopen = function() {} +server.onmessage = function( message, source, room ) {} +server.onerror = function( error ) {} + +server.send( message, uid, room ) + +server.uid() // Returns UID +server.room() // Returns room + ## License This code is under the Affero GNU General Public License. I am willing to From 4b90e0b45f70f0957cb7d4c844b1e7025278a7e5 Mon Sep 17 00:00:00 2001 From: Will Holcomb Date: Fri, 28 Jun 2013 23:17:27 -0400 Subject: [PATCH 04/12] guessing at markdown --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 99fbeb9..52a76ef 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ the bandwidth is high, but not infinite... :-) ## API -var server = new SimpleSignaling( { +```var server = new SimpleSignaling( { // The SimpleSignaling server ws_uri: 'ws://ec2-54-242-188-68.compute-1.amazonaws.com:8080', room: 'broadcast-test', // Optional, not really used in this example @@ -35,7 +35,7 @@ server.onerror = function( error ) {} server.send( message, uid, room ) server.uid() // Returns UID -server.room() // Returns room +server.room() // Returns room``` ## License From eb54d361973a754834a4f6980ffdb825af1b5d3c Mon Sep 17 00:00:00 2001 From: Will Holcomb Date: Fri, 28 Jun 2013 23:19:29 -0400 Subject: [PATCH 05/12] fixed markdown --- README.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 52a76ef..0038fa6 100644 --- a/README.md +++ b/README.md @@ -21,21 +21,21 @@ the bandwidth is high, but not infinite... :-) ## API -```var server = new SimpleSignaling( { - // The SimpleSignaling server - ws_uri: 'ws://ec2-54-242-188-68.compute-1.amazonaws.com:8080', - room: 'broadcast-test', // Optional, not really used in this example - uid: 'user identifier' // Optional, a [UUIDv4](//en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_.28random.29) will be generated -} ) - -server.onopen = function() {} -server.onmessage = function( message, source, room ) {} -server.onerror = function( error ) {} - -server.send( message, uid, room ) - -server.uid() // Returns UID -server.room() // Returns room``` + var server = new SimpleSignaling( { + // The SimpleSignaling server + ws_uri: 'ws://ec2-54-242-188-68.compute-1.amazonaws.com:8080', + room: 'broadcast-test', // Optional, not really used in this example + uid: 'user identifier' // Optional, a [UUIDv4](//en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_.28random.29) will be generated + } ) + + server.onopen = function() {} + server.onmessage = function( message, source, room ) {} + server.onerror = function( error ) {} + + server.send( message, uid, room ) + + server.uid() // Returns UID + server.room() // Returns room ## License From e43db0e66605ebf46faf769eb613db621620f480 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Sun, 30 Jun 2013 16:20:47 +0000 Subject: [PATCH 06/12] logging to a file to debug crashes --- bin/run_server | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/run_server b/bin/run_server index 2a426fe..746fe51 100755 --- a/bin/run_server +++ b/bin/run_server @@ -2,8 +2,8 @@ pushd "${0%/*}/../" -until nodejs server.js; do - echo "Server crashed with exit code $?. Respawning.." >&2 +until nodejs server.js 2>&1 >> server.log; do + echo "Server crashed with exit code $?. Respawning.." >> server.log sleep 1 done From a3e83896880813ca64be9ce92904dceee6f73bc1 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Sun, 30 Jun 2013 16:28:56 +0000 Subject: [PATCH 07/12] adding server.log --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 07e6e47..bdb5d3a 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /node_modules +server.log \ No newline at end of file From ee10f3763f3bf46e809ef798d7d056e570b2995b Mon Sep 17 00:00:00 2001 From: Will Holcomb Date: Mon, 1 Jul 2013 18:30:17 -0400 Subject: [PATCH 08/12] adding instructions --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 0038fa6..e1000ca 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,13 @@ the bandwidth is high, but not infinite... :-) server.uid() // Returns UID server.room() // Returns room +## Running on [Ubuntu](//www.ubuntu.com/) + +* `sudo apt-get install git nodejs npm` +* `git clone //github.com/wholcomb/SimpleSignaling` +* `npm install ws` +* `./SimpleSignaling/bin/(run_server)[bin/run_server]` + ## License This code is under the Affero GNU General Public License. I am willing to From 352c20ea0b80d4e29580cb1603b3d651eb768f42 Mon Sep 17 00:00:00 2001 From: Will Holcomb Date: Mon, 1 Jul 2013 18:32:36 -0400 Subject: [PATCH 09/12] fixed link typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e1000ca..dbd4f86 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ the bandwidth is high, but not infinite... :-) * `sudo apt-get install git nodejs npm` * `git clone //github.com/wholcomb/SimpleSignaling` * `npm install ws` -* `./SimpleSignaling/bin/(run_server)[bin/run_server]` +* `./SimpleSignaling/bin/[run_server](bin/run_server)` ## License From 6807494ccdccc447eb444f694958a7e0ac1506b6 Mon Sep 17 00:00:00 2001 From: Will Holcomb Date: Mon, 1 Jul 2013 18:33:37 -0400 Subject: [PATCH 10/12] links not allowed in code blocks --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dbd4f86..4dbd44e 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ the bandwidth is high, but not infinite... :-) * `sudo apt-get install git nodejs npm` * `git clone //github.com/wholcomb/SimpleSignaling` * `npm install ws` -* `./SimpleSignaling/bin/[run_server](bin/run_server)` +* `./SimpleSignaling/bin/run_server` ## License From 8cfff0657d0fabff1db5e7f68b274beecece4a53 Mon Sep 17 00:00:00 2001 From: Will Holcomb Date: Wed, 3 Jul 2013 14:50:48 -0400 Subject: [PATCH 11/12] reverting undefined checks --- simpleSignaling.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/simpleSignaling.js b/simpleSignaling.js index ef4cc6d..191b488 100644 --- a/simpleSignaling.js +++ b/simpleSignaling.js @@ -6,7 +6,7 @@ function SimpleSignaling(configuration) { var self = this; - var room = configuration.room || 'default room'; + var room = (configuration.room != undefined) ? configuration.room : 'default room'; /** * UUID generator @@ -15,7 +15,7 @@ function SimpleSignaling(configuration) // (e.g., f47ac10b-58cc-4372-a567-0e02b2c3d479). var UUIDv4 = function b(a){return a?(a^Math.random()*16>>a/4).toString(16):([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,b)}; - var uid = configuration.uid || UUIDv4(); + var uid = (configuration.uid != undefined) ? configuration.uid : UUIDv4(); var websocket = new WebSocket(configuration.ws_uri); websocket.onopen = function() From 320dd8e00786314d85db49aac90e75c01e246b77 Mon Sep 17 00:00:00 2001 From: Will Date: Wed, 3 Jul 2013 21:45:35 -0400 Subject: [PATCH 12/12] fixing url --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4dbd44e..5ed5408 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ the bandwidth is high, but not infinite... :-) ## Running on [Ubuntu](//www.ubuntu.com/) * `sudo apt-get install git nodejs npm` -* `git clone //github.com/wholcomb/SimpleSignaling` +* `git clone http://github.com/wholcomb/SimpleSignaling` * `npm install ws` * `./SimpleSignaling/bin/run_server`