Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/node_modules
server.log
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions bin/run_server
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ('<a href="http://github.com/piranna/SimpleSignaling">GitHub</a>');
res.end ('<a href="//github.com/ShareIt-project/SimpleSignaling">GitHub</a>');
}

var server = require('http').createServer(requestListener);
Expand Down
2 changes: 2 additions & 0 deletions simpleSignaling.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down