mirror of
https://github.com/dani/vroom.git
synced 2024-06-30 07:13:41 +02:00
Rebase signal master to current GIT
This commit is contained in:
parent
05131716a6
commit
15ba0508fe
|
@ -6,8 +6,9 @@
|
||||||
"evil": true,
|
"evil": true,
|
||||||
"white": true,
|
"white": true,
|
||||||
"undef": true,
|
"undef": true,
|
||||||
"node": true,
|
"browser": true,
|
||||||
"predef": [
|
"predef": [
|
||||||
|
"app",
|
||||||
"$",
|
"$",
|
||||||
"FormBot",
|
"FormBot",
|
||||||
"socket",
|
"socket",
|
||||||
|
|
1
signalmaster/Procfile
Normal file
1
signalmaster/Procfile
Normal file
|
@ -0,0 +1 @@
|
||||||
|
web: node server.js
|
|
@ -4,7 +4,9 @@ A simple signaling server for clients to connect and do signaling for WebRTC.
|
||||||
|
|
||||||
Specifically created as a default connection point for [SimpleWebRTC.js](https://github.com/HenrikJoreteg/SimpleWebRTC)
|
Specifically created as a default connection point for [SimpleWebRTC.js](https://github.com/HenrikJoreteg/SimpleWebRTC)
|
||||||
|
|
||||||
|
It also supports vending STUN/TURN servers with the shared secret mechanism as described in [this draft](http://tools.ietf.org/html/draft-uberti-behave-turn-rest-00).
|
||||||
|
|
||||||
Read more:
|
Read more:
|
||||||
- [Introducing SimpleWebRTC and conversat.io](http://blog.andyet.com/2013/feb/22/introducing-simplewebrtcjs-and-conversatio/)
|
- [Introducing SimpleWebRTC and conversat.io](http://blog.andyet.com/2013/feb/22/introducing-simplewebrtcjs-and-conversatio/)
|
||||||
- [SimpleWebRTC.com](http://simplewebrtc.com)
|
- [SimpleWebRTC.com](http://simplewebrtc.com)
|
||||||
- [conversat.io](http://conversat.io)
|
- [talky.io](https://talky.io)
|
||||||
|
|
|
@ -1,8 +1,17 @@
|
||||||
{
|
{
|
||||||
"isDev": false,
|
"isDev": false,
|
||||||
|
"logLevel": 3,
|
||||||
"server": {
|
"server": {
|
||||||
"port": 8888
|
"port": 8888
|
||||||
},
|
},
|
||||||
|
/*"stunservers" : [
|
||||||
|
{"url": "stun:stun.l.google.com:19302"}
|
||||||
|
],
|
||||||
|
"turnservers" : [
|
||||||
|
{ "url": "turn:your.turn.server.here",
|
||||||
|
"secret": "turnserversharedsecret"
|
||||||
|
"expiry": 86400 }
|
||||||
|
]*/
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"server": "localhost",
|
"server": "localhost",
|
||||||
"database": "vroom",
|
"database": "vroom",
|
||||||
|
|
|
@ -1,21 +1,17 @@
|
||||||
{
|
{
|
||||||
"name": "signal-master",
|
"name": "signal-master",
|
||||||
"version": "0.0.1",
|
"description": "Simple signaling server for SimpleWebRTC",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"dependencies": {
|
||||||
|
"getconfig": "0.3.0",
|
||||||
|
"node-uuid": "1.2.0",
|
||||||
|
"socket.io": "0.9.16",
|
||||||
|
"mysql": "",
|
||||||
|
"cookie": ""
|
||||||
|
},
|
||||||
|
"main": "server.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git@github.com:andyet/signal-master.git"
|
"url": "git@github.com:andyet/signal-master.git"
|
||||||
},
|
}
|
||||||
"description": "Mind-meldification for teams",
|
|
||||||
"dependencies": {
|
|
||||||
"async": "0.1.9",
|
|
||||||
"node-uuid": "1.2.0",
|
|
||||||
"redis": "",
|
|
||||||
"underscore": "",
|
|
||||||
"precommit-hook": "",
|
|
||||||
"getconfig": "",
|
|
||||||
"socket.io": "",
|
|
||||||
"mysql":"",
|
|
||||||
"cookie":""
|
|
||||||
},
|
|
||||||
"main": "server.js"
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,9 @@ var config = require('getconfig'),
|
||||||
uuid = require('node-uuid'),
|
uuid = require('node-uuid'),
|
||||||
mysql = require('mysql'),
|
mysql = require('mysql'),
|
||||||
cookie_reader = require('cookie'),
|
cookie_reader = require('cookie'),
|
||||||
io = require('socket.io').listen(config.server.port);
|
crypto = require('crypto'),
|
||||||
|
port = parseInt(process.env.PORT || config.server.port, 10),
|
||||||
|
io = require('socket.io').listen(port);
|
||||||
|
|
||||||
var sql = mysql.createConnection({
|
var sql = mysql.createConnection({
|
||||||
host : config.mysql.server,
|
host : config.mysql.server,
|
||||||
|
@ -11,6 +13,11 @@ var sql = mysql.createConnection({
|
||||||
user : config.mysql.user,
|
user : config.mysql.user,
|
||||||
password : config.mysql.password});
|
password : config.mysql.password});
|
||||||
|
|
||||||
|
if (config.logLevel) {
|
||||||
|
// https://github.com/Automattic/socket.io/wiki/Configuring-Socket.IO
|
||||||
|
io.set('log level', config.logLevel);
|
||||||
|
}
|
||||||
|
|
||||||
function describeRoom(name) {
|
function describeRoom(name) {
|
||||||
var clients = io.sockets.clients(name);
|
var clients = io.sockets.clients(name);
|
||||||
var result = {
|
var result = {
|
||||||
|
@ -94,24 +101,30 @@ io.sockets.on('connection', function (client) {
|
||||||
|
|
||||||
client.on('unshareScreen', function (type) {
|
client.on('unshareScreen', function (type) {
|
||||||
client.resources.screen = false;
|
client.resources.screen = false;
|
||||||
if (client.room) removeFeed('screen');
|
removeFeed('screen');
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('join', join);
|
client.on('join', join);
|
||||||
|
|
||||||
function removeFeed(type) {
|
function removeFeed(type) {
|
||||||
|
if (client.room) {
|
||||||
io.sockets.in(client.room).emit('remove', {
|
io.sockets.in(client.room).emit('remove', {
|
||||||
id: client.id,
|
id: client.id,
|
||||||
type: type
|
type: type
|
||||||
});
|
});
|
||||||
|
if (!type) {
|
||||||
|
client.leave(client.room);
|
||||||
|
client.room = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function join(name, cb) {
|
function join(name, cb) {
|
||||||
// sanity check
|
// sanity check
|
||||||
if (typeof name !== 'string') return;
|
if (typeof name !== 'string') return;
|
||||||
// leave any existing rooms
|
// leave any existing rooms
|
||||||
if (client.room) removeFeed();
|
removeFeed();
|
||||||
safeCb(cb)(null, describeRoom(name))
|
safeCb(cb)(null, describeRoom(name));
|
||||||
client.join(name);
|
client.join(name);
|
||||||
client.room = name;
|
client.room = name;
|
||||||
}
|
}
|
||||||
|
@ -121,7 +134,9 @@ io.sockets.on('connection', function (client) {
|
||||||
client.on('disconnect', function () {
|
client.on('disconnect', function () {
|
||||||
removeFeed();
|
removeFeed();
|
||||||
});
|
});
|
||||||
client.on('leave', removeFeed);
|
client.on('leave', function () {
|
||||||
|
removeFeed();
|
||||||
|
});
|
||||||
|
|
||||||
client.on('create', function (name, cb) {
|
client.on('create', function (name, cb) {
|
||||||
if (arguments.length == 2) {
|
if (arguments.length == 2) {
|
||||||
|
@ -139,7 +154,29 @@ io.sockets.on('connection', function (client) {
|
||||||
safeCb(cb)(null, name);
|
safeCb(cb)(null, name);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// tell client about stun and turn servers and generate nonces
|
||||||
|
if (config.stunservers) {
|
||||||
|
client.emit('stunservers', config.stunservers);
|
||||||
|
}
|
||||||
|
if (config.turnservers) {
|
||||||
|
// create shared secret nonces for TURN authentication
|
||||||
|
// the process is described in draft-uberti-behave-turn-rest
|
||||||
|
var credentials = [];
|
||||||
|
config.turnservers.forEach(function (server) {
|
||||||
|
var hmac = crypto.createHmac('sha1', server.secret);
|
||||||
|
// default to 86400 seconds timeout unless specified
|
||||||
|
var username = Math.floor(new Date().getTime() / 1000) + (server.expiry || 86400) + "";
|
||||||
|
hmac.update(username);
|
||||||
|
credentials.push({
|
||||||
|
username: username,
|
||||||
|
credential: hmac.digest('base64'),
|
||||||
|
url: server.url
|
||||||
|
});
|
||||||
|
});
|
||||||
|
client.emit('turnservers', credentials);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (config.uid) process.setuid(config.uid);
|
if (config.uid) process.setuid(config.uid);
|
||||||
console.log('signal master is running at: http://localhost:' + config.server.port);
|
console.log('signal master is running at: http://localhost:' + port);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user