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
diff --git a/README.md b/README.md
index 82136cc..5ed5408 100644
--- a/README.md
+++ b/README.md
@@ -19,6 +19,31 @@ 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
+
+## Running on [Ubuntu](//www.ubuntu.com/)
+
+* `sudo apt-get install git nodejs npm`
+* `git clone http://github.com/wholcomb/SimpleSignaling`
+* `npm install ws`
+* `./SimpleSignaling/bin/run_server`
+
## License
This code is under the Affero GNU General Public License. I am willing to
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
diff --git a/server.js b/server.js
index 0fc1d34..1b8f6f6 100644
--- a/server.js
+++ b/server.js
@@ -8,13 +8,15 @@ 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)
{
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..191b488 100644
--- a/simpleSignaling.js
+++ b/simpleSignaling.js
@@ -11,6 +11,8 @@ function SimpleSignaling(configuration)
/**
* 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();