Various small changes.

master
Håvar Aambø Fosstveit 2019-10-23 19:46:44 +02:00
parent dd9f95971d
commit 6596deda2a
14 changed files with 319 additions and 403 deletions

View File

@ -610,61 +610,44 @@ export default class RoomClient
const {
chatHistory,
fileHistory,
lastN,
lastNHistory,
locked,
lobbyPeers,
accessCode
} = await this.sendRequest('serverHistory');
if (chatHistory.length > 0)
{
logger.debug('Got chat history');
store.dispatch(
(chatHistory.length > 0) && store.dispatch(
stateActions.addChatHistory(chatHistory));
}
if (fileHistory.length > 0)
(fileHistory.length > 0) && store.dispatch(
stateActions.addFileHistory(fileHistory));
if (lastNHistory.length > 0)
{
logger.debug('Got files history');
store.dispatch(stateActions.addFileHistory(fileHistory));
}
if (lastN.length > 0)
{
logger.debug('Got lastN');
logger.debug('Got lastNHistory');
// Remove our self from list
const index = lastN.indexOf(this._peerId);
const index = lastNHistory.indexOf(this._peerId);
lastN.splice(index, 1);
lastNHistory.splice(index, 1);
this._spotlights.addSpeakerList(lastN);
this._spotlights.addSpeakerList(lastNHistory);
}
locked ?
store.dispatch(stateActions.setRoomLocked()) :
store.dispatch(stateActions.setRoomUnLocked());
if (lobbyPeers.length > 0)
{
logger.debug('Got lobby peers');
lobbyPeers.forEach((peer) =>
(lobbyPeers.length > 0) && lobbyPeers.forEach((peer) =>
{
store.dispatch(
stateActions.addLobbyPeer(peer.peerId));
store.dispatch(
stateActions.setLobbyPeerDisplayName(peer.displayName));
});
}
if (accessCode != null)
{
logger.debug('Got accessCode');
store.dispatch(stateActions.setAccessCode(accessCode))
}
(accessCode != null) && store.dispatch(
stateActions.setAccessCode(accessCode));
}
catch (error)
{

View File

@ -1,4 +1,4 @@
import React from 'react';
import React, { useState } from 'react';
import { connect } from 'react-redux';
import { withStyles } from '@material-ui/core/styles';
import { withRoomContext } from '../RoomContext';
@ -58,6 +58,28 @@ const JoinDialog = ({
classes
}) =>
{
const [ localDisplayName, setLocalDisplayName ] = useState(displayName);
const handleKeyDown = (event) =>
{
const { key } = event;
switch (key)
{
case 'Enter':
case 'Escape':
{
if (localDisplayName !== '') // Don't allow empty displayName
changeDisplayName(localDisplayName);
else
setLocalDisplayName(displayName);
break;
}
default:
break;
}
};
return (
<div className={classes.root}>
<Dialog
@ -69,21 +91,30 @@ const JoinDialog = ({
{ window.config.logo &&
<img alt='Logo' className={classes.logo} src={window.config.logo} />
}
<Typography variant='subtitle1'>
<Typography variant='h2' align='center'>
Welcome
</Typography>
<Typography variant='h6'>
You are about to join a meeting.
Set your name that others will see,
and chose how you want to join?
Set the name that others will see,
and choose how you want to join?
</Typography>
<TextField
id='displayname'
label='Name'
label='Your name'
className={classes.textField}
value={displayName}
value={localDisplayName}
onChange={(event) =>
{
const { value } = event.target;
changeDisplayName(value);
setLocalDisplayName(value);
}}
onKeyDown={handleKeyDown}
onBlur={() =>
{
if (localDisplayName !== displayName)
changeDisplayName(localDisplayName);
}}
margin='normal'
/>
@ -94,6 +125,17 @@ const JoinDialog = ({
roomClient.join({ joinVideo: false });
}}
variant='contained'
color='secondary'
>
Sign in
</Button>
<Button
onClick={() =>
{
roomClient.join({ joinVideo: false });
}}
variant='contained'
color='secondary'
>
Audio only
</Button>
@ -103,6 +145,7 @@ const JoinDialog = ({
roomClient.join({ joinVideo: true });
}}
variant='contained'
color='secondary'
>
Audio and Video
</Button>

View File

@ -29,7 +29,8 @@ export default class PeerAudio extends React.PureComponent
this._setTrack(audioTrack);
}
componentWillReceiveProps(nextProps)
// eslint-disable-next-line camelcase
UNSAFE_componentWillReceiveProps(nextProps)
{
const { audioTrack } = nextProps;

View File

@ -247,7 +247,8 @@ class VideoView extends React.PureComponent
clearInterval(this._videoResolutionTimer);
}
componentWillReceiveProps(nextProps)
// eslint-disable-next-line camelcase
UNSAFE_componentWillReceiveProps(nextProps)
{
const { videoTrack } = nextProps;

View File

@ -1,168 +0,0 @@
module.exports =
{
env:
{
browser: true,
es6: true,
node: true
},
extends:
[
'eslint:recommended'
],
settings: {},
parserOptions:
{
ecmaVersion: 6,
sourceType: 'module',
ecmaFeatures:
{
impliedStrict: true
}
},
rules:
{
'array-bracket-spacing': [ 2, 'always',
{
objectsInArrays: true,
arraysInArrays: true
}],
'arrow-parens': [ 2, 'always' ],
'arrow-spacing': 2,
'block-spacing': [ 2, 'always' ],
'brace-style': [ 2, 'allman', { allowSingleLine: true } ],
'camelcase': 2,
'comma-dangle': 2,
'comma-spacing': [ 2, { before: false, after: true } ],
'comma-style': 2,
'computed-property-spacing': 2,
'constructor-super': 2,
'func-call-spacing': 2,
'generator-star-spacing': 2,
'guard-for-in': 2,
'indent': [ 2, 'tab', { 'SwitchCase': 1 } ],
'key-spacing': [ 2,
{
singleLine:
{
beforeColon: false,
afterColon: true
},
multiLine:
{
beforeColon: true,
afterColon: true,
align: 'colon'
}
}],
'keyword-spacing': 2,
'linebreak-style': [ 2, 'unix' ],
'lines-around-comment': [ 2,
{
allowBlockStart: true,
allowObjectStart: true,
beforeBlockComment: true,
beforeLineComment: false
}],
'max-len': [ 2, 90,
{
tabWidth: 2,
comments: 110,
ignoreUrls: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
ignoreRegExpLiterals: true
}],
'newline-after-var': 2,
'newline-before-return': 2,
'newline-per-chained-call': 2,
'no-alert': 2,
'no-caller': 2,
'no-case-declarations': 2,
'no-catch-shadow': 2,
'no-class-assign': 2,
'no-confusing-arrow': 2,
'no-console': 2,
'no-const-assign': 2,
'no-debugger': 2,
'no-dupe-args': 2,
'no-dupe-keys': 2,
'no-duplicate-case': 2,
'no-div-regex': 2,
'no-empty': [ 2, { allowEmptyCatch: true } ],
'no-empty-pattern': 2,
'no-else-return': 0,
'no-eval': 2,
'no-extend-native': 2,
'no-ex-assign': 2,
'no-extra-bind': 2,
'no-extra-boolean-cast': 2,
'no-extra-label': 2,
'no-extra-semi': 2,
'no-fallthrough': 2,
'no-func-assign': 2,
'no-global-assign': 2,
'no-implicit-coercion': 2,
'no-implicit-globals': 2,
'no-inner-declarations': 2,
'no-invalid-regexp': 2,
'no-invalid-this': 2,
'no-irregular-whitespace': 2,
'no-lonely-if': 2,
'no-mixed-operators': 2,
'no-mixed-spaces-and-tabs': 2,
'no-multi-spaces': 2,
'no-multi-str': 2,
'no-multiple-empty-lines': [ 2, { max: 1, maxEOF: 0, maxBOF: 0 } ],
'no-native-reassign': 2,
'no-negated-in-lhs': 2,
'no-new': 2,
'no-new-func': 2,
'no-new-wrappers': 2,
'no-obj-calls': 2,
'no-proto': 2,
'no-prototype-builtins': 0,
'no-redeclare': 2,
'no-regex-spaces': 2,
'no-restricted-imports': 2,
'no-return-assign': 2,
'no-self-assign': 2,
'no-self-compare': 2,
'no-sequences': 2,
'no-shadow': 2,
'no-shadow-restricted-names': 2,
'no-spaced-func': 2,
'no-sparse-arrays': 2,
'no-this-before-super': 2,
'no-throw-literal': 2,
'no-undef': 2,
'no-unexpected-multiline': 2,
'no-unmodified-loop-condition': 2,
'no-unreachable': 2,
'no-unused-vars': [ 1, { vars: 'all', args: 'after-used' }],
'no-use-before-define': [ 2, { functions: false } ],
'no-useless-call': 2,
'no-useless-computed-key': 2,
'no-useless-concat': 2,
'no-useless-rename': 2,
'no-var': 2,
'no-whitespace-before-property': 2,
'object-curly-newline': 0,
'object-curly-spacing': [ 2, 'always' ],
'object-property-newline': [ 2, { allowMultiplePropertiesPerLine: true } ],
'prefer-const': 2,
'prefer-rest-params': 2,
'prefer-spread': 2,
'prefer-template': 2,
'quotes': [ 2, 'single', { avoidEscape: true } ],
'semi': [ 2, 'always' ],
'semi-spacing': 2,
'space-before-blocks': 2,
'space-before-function-paren': [ 2, 'never' ],
'space-in-parens': [ 2, 'never' ],
'spaced-comment': [ 2, 'always' ],
'strict': 0,
'valid-typeof': 2,
'yoda': 2
}
};

View File

@ -0,0 +1,171 @@
{
"env":
{
"es6": true,
"node": true
},
"extends":
[
"eslint:recommended"
],
"settings": {},
"parserOptions":
{
"ecmaVersion": 2018,
"sourceType": "module",
"ecmaFeatures":
{
"impliedStrict": true
}
},
"rules":
{
"array-bracket-spacing": [ 2, "always",
{
"objectsInArrays": true,
"arraysInArrays": true
}],
"arrow-parens": [ 2, "always" ],
"arrow-spacing": 2,
"block-spacing": [ 2, "always" ],
"brace-style": [ 2, "allman", { "allowSingleLine": true } ],
"camelcase": 2,
"comma-dangle": 2,
"comma-spacing": [ 2, { "before": false, "after": true } ],
"comma-style": 2,
"computed-property-spacing": 2,
"constructor-super": 2,
"func-call-spacing": 2,
"generator-star-spacing": 2,
"guard-for-in": 2,
"indent": [ 2, "tab", { "SwitchCase": 1 } ],
"key-spacing": [ 2,
{
"singleLine":
{
"beforeColon": false,
"afterColon": true
},
"multiLine":
{
"beforeColon": true,
"afterColon": true,
"align": "colon"
}
}],
"keyword-spacing": 2,
"linebreak-style": [ 2, "unix" ],
"lines-around-comment": [ 2,
{
"allowBlockStart": true,
"allowObjectStart": true,
"beforeBlockComment": true,
"beforeLineComment": false
}],
"max-len": [ 2, 90,
{
"tabWidth": 2,
"comments": 90,
"ignoreUrls": true,
"ignoreStrings": true,
"ignoreTemplateLiterals": true,
"ignoreRegExpLiterals": true
}],
"newline-after-var": 2,
"newline-before-return": 2,
"newline-per-chained-call": 2,
"no-alert": 2,
"no-caller": 2,
"no-case-declarations": 2,
"no-catch-shadow": 2,
"no-class-assign": 2,
"no-confusing-arrow": 2,
"no-console": 2,
"no-const-assign": 2,
"no-debugger": 2,
"no-dupe-args": 2,
"no-dupe-keys": 2,
"no-duplicate-case": 2,
"no-div-regex": 2,
"no-empty": [ 2, { "allowEmptyCatch": true } ],
"no-empty-pattern": 2,
"no-else-return": 0,
"no-eval": 2,
"no-extend-native": 2,
"no-ex-assign": 2,
"no-extra-bind": 2,
"no-extra-boolean-cast": 2,
"no-extra-label": 2,
"no-extra-semi": 2,
"no-fallthrough": 2,
"no-func-assign": 2,
"no-global-assign": 2,
"no-implicit-coercion": 2,
"no-implicit-globals": 2,
"no-inner-declarations": 2,
"no-invalid-regexp": 2,
"no-invalid-this": 2,
"no-irregular-whitespace": 2,
"no-lonely-if": 2,
"no-mixed-operators": 2,
"no-mixed-spaces-and-tabs": 2,
"no-multi-spaces": 2,
"no-multi-str": 2,
"no-multiple-empty-lines": [ 1, { "max": 1, "maxEOF": 0, "maxBOF": 0 } ],
"no-native-reassign": 2,
"no-negated-in-lhs": 2,
"no-new": 2,
"no-new-func": 2,
"no-new-wrappers": 2,
"no-obj-calls": 2,
"no-proto": 2,
"no-prototype-builtins": 0,
"no-redeclare": 2,
"no-regex-spaces": 2,
"no-restricted-imports": 2,
"no-return-assign": 2,
"no-self-assign": 2,
"no-self-compare": 2,
"no-sequences": 2,
"no-shadow": 2,
"no-shadow-restricted-names": 2,
"no-spaced-func": 2,
"no-sparse-arrays": 2,
"no-this-before-super": 2,
"no-throw-literal": 2,
"no-undef": 2,
"no-unexpected-multiline": 2,
"no-unmodified-loop-condition": 2,
"no-unreachable": 2,
"no-unused-vars": [ 1, { "vars": "all", "args": "after-used" }],
"no-use-before-define": [ 2, { "functions": false } ],
"no-useless-call": 2,
"no-useless-computed-key": 2,
"no-useless-concat": 2,
"no-useless-rename": 2,
"no-var": 2,
"no-whitespace-before-property": 2,
"object-curly-newline": 0,
"object-curly-spacing": [ 2, "always" ],
"object-property-newline": [ 2, { "allowMultiplePropertiesPerLine": true } ],
"prefer-const": 2,
"prefer-rest-params": 2,
"prefer-spread": 2,
"prefer-template": 2,
"quotes": [ 2, "single", { "avoidEscape": true } ],
"semi": [ 2, "always" ],
"semi-spacing": 2,
"space-before-blocks": 2,
"space-before-function-paren": [ 2,
{
"anonymous" : "never",
"named" : "never",
"asyncArrow" : "always"
}],
"space-in-parens": [ 2, "never" ],
"spaced-comment": [ 2, "always" ],
"strict": 2,
"valid-typeof": 2,
"yoda": 2
}
}

View File

@ -1,44 +0,0 @@
/**
* Tasks:
*
* gulp lint
* Checks source code
*
* gulp watch
* Observes changes in the code
*
* gulp
* Invokes both `lint` and `watch` tasks
*/
const gulp = require('gulp');
const plumber = require('gulp-plumber');
const eslint = require('gulp-eslint');
const LINTING_FILES =
[
'gulpfile.js',
'server.js',
'config/config.example.js',
'lib/**/*.js'
];
gulp.task('lint', () =>
{
return gulp.src(LINTING_FILES)
.pipe(plumber())
.pipe(eslint())
.pipe(eslint.format());
});
gulp.task('lint-fix', function()
{
return gulp.src(LINTING_FILES)
.pipe(plumber())
.pipe(eslint({ fix: true }))
.pipe(eslint.format())
.pipe(gulp.dest((file) => file.base));
});
gulp.task('default', gulp.series('lint'));

View File

@ -1,43 +0,0 @@
'use strict';
const headers = {
'access-control-allow-origin': '*',
'access-control-allow-methods': 'GET, POST, PUT, DELETE, OPTIONS',
'access-control-allow-headers': 'content-type, accept',
'access-control-max-age': 10,
'Content-Type': 'application/json'
};
exports.prepareResponse = (req, cb) =>
{
let data = '';
req.on('data', (chunk) =>
{
data += chunk;
});
req.on('end', () =>
{
cb(data);
});
};
exports.respond = (res, data, status) =>
{
status = status || 200;
res.writeHead(status, headers);
res.end(data);
};
exports.send404 = (res) =>
{
exports.respond(res, 'Not Found', 404);
};
exports.redirector = (res, loc, status) =>
{
status = status || 302;
res.writeHead(status, { Location: loc });
res.end();
};

View File

@ -1,5 +1,3 @@
'use strict';
const EventEmitter = require('events').EventEmitter;
const Logger = require('./Logger');
@ -38,7 +36,11 @@ class Lobby extends EventEmitter
{
logger.info('peerList()');
return Object.values(this._peers).map((peer) => ({ peerId: peer.peerId, displayName: peer.displayName }));
return Object.values(this._peers).map((peer) =>
({
peerId : peer.peerId,
displayName : peer.displayName
}));
}
hasPeer(peerId)

View File

@ -1,5 +1,3 @@
'use strict';
const debug = require('debug');
const APP_NAME = 'multiparty-meeting-server';

View File

@ -1,5 +1,3 @@
'use strict';
const EventEmitter = require('events').EventEmitter;
const Logger = require('./Logger');
const Lobby = require('./Lobby');
@ -23,7 +21,7 @@ class Room extends EventEmitter
logger.info('create() [roomId:%s, forceH264:%s]', roomId);
// Router media codecs.
let mediaCodecs = config.mediasoup.router.mediaCodecs;
const mediaCodecs = config.mediasoup.router.mediaCodecs;
// Create a mediasoup Router.
const mediasoupRouter = await mediasoupWorker.createRouter({ mediaCodecs });
@ -58,18 +56,19 @@ class Room extends EventEmitter
// if true: accessCode is a possibility to open the room
this._joinByAccesCode = true;
// access code to the room, applicable if ( _locked == true and _joinByAccessCode == true )
// access code to the room,
// applicable if ( _locked == true and _joinByAccessCode == true )
this._accessCode = '';
this._lobby = new Lobby();
this._lobby.on('promotePeer', (peer) =>
this._lobby.on('promotePeer', (promotedPeer) =>
{
logger.info('promotePeer() [peer:"%o"]', peer);
logger.info('promotePeer() [promotedPeer:"%o"]', promotedPeer);
const { peerId } = peer;
const { peerId } = promotedPeer;
this._peerJoining({ ...peer });
this._peerJoining({ ...promotedPeer });
Object.values(this._peers).forEach((peer) =>
{
@ -77,9 +76,9 @@ class Room extends EventEmitter
});
});
this._lobby.on('lobbyPeerDisplayNameChanged', (peer) =>
this._lobby.on('lobbyPeerDisplayNameChanged', (changedPeer) =>
{
const { peerId, displayName } = peer;
const { peerId, displayName } = changedPeer;
Object.values(this._peers).forEach((peer) =>
{
@ -87,11 +86,11 @@ class Room extends EventEmitter
});
});
this._lobby.on('peerClosed', (peer) =>
this._lobby.on('peerClosed', (closedPeer) =>
{
logger.info('peerClosed() [peer:"%o"]', peer);
logger.info('peerClosed() [closedPeer:"%o"]', closedPeer);
const { peerId } = peer;
const { peerId } = closedPeer;
Object.values(this._peers).forEach((peer) =>
{
@ -243,13 +242,13 @@ class Room extends EventEmitter
return this._locked;
}
peerAuthenticated(peerid)
peerAuthenticated(peerId)
{
logger.debug('peerAuthenticated() | [peerId:"%s"]', peerId);
if (!this._locked)
{
if (!Boolean(this._peers[peerid]))
if (!this._peers[peerId])
{
this._lobby.promotePeer(peerId);
}
@ -810,12 +809,13 @@ class Room extends EventEmitter
{
// Return to sender
const lobbyPeers = this._lobby.peerList();
cb(
null,
{
chatHistory : this._chatHistory,
fileHistory : this._fileHistory,
lastN : this._lastN,
lastNHistory : this._lastN,
locked : this._locked,
lobbyPeers : lobbyPeers,
accessCode : this._accessCode
@ -893,7 +893,6 @@ class Room extends EventEmitter
break;
}
case 'promotePeer':
{
const { peerId } = request.data;
@ -1080,7 +1079,6 @@ class Room extends EventEmitter
kind : producer.kind,
producerId : producer.id,
id : consumer.id,
kind : consumer.kind,
rtpParameters : consumer.rtpParameters,
type : consumer.type,
appData : producer.appData,

View File

@ -20,10 +20,5 @@
"passport": "^0.4.0",
"socket.io": "^2.3.0",
"spdy": "^4.0.1"
},
"devDependencies": {
"gulp": "^4.0.2",
"gulp-eslint": "^6.0.0",
"gulp-plumber": "^1.2.1"
}
}

View File

@ -1,7 +1,5 @@
#!/usr/bin/env node
'use strict';
process.title = 'multiparty-meeting-server';
const config = require('./config/config');
@ -14,7 +12,6 @@ const mediasoup = require('mediasoup');
const AwaitQueue = require('awaitqueue');
const Logger = require('./lib/Logger');
const Room = require('./lib/Room');
const utils = require('./util');
const base64 = require('base-64');
// auth
const passport = require('passport');
@ -26,7 +23,7 @@ const sharedSession = require('express-socket.io-session');
console.log('- process.env.DEBUG:', process.env.DEBUG);
console.log('- config.mediasoup.logLevel:', config.mediasoup.logLevel);
console.log('- config.mediasoup.logTags:', config.mediasoup.logTags);
/* eslint-enable nopassportSocketIo-console */
/* eslint-enable no-console */
const logger = new Logger();
@ -57,11 +54,12 @@ const session = expressSession({
resave : true,
saveUninitialized : true,
cookie : { secure: true }
})
});
app.use(session);
let httpsServer;
let io;
let oidcClient;
let oidcStrategy;
@ -219,8 +217,7 @@ async function setupAuth(oidcIssuer)
state : base64.encode(JSON.stringify({
id : req.query.id,
roomId : req.query.roomId,
peerId : req.query.peerId,
code : utils.random(10)
peerId : req.query.peerId
}))
})(req, res, next);
});
@ -325,7 +322,7 @@ async function runHttpsServer()
*/
async function runWebSocketServer()
{
const io = require('socket.io')(httpsServer);
io = require('socket.io')(httpsServer);
io.use(
sharedSession(session, {

View File

@ -1,18 +0,0 @@
'use strict';
var crypto = require('crypto');
exports.random = function (howMany, chars) {
chars = chars
|| "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789";
var rnd = crypto.randomBytes(howMany)
, value = new Array(howMany)
, len = len = Math.min(256, chars.length)
, d = 256 / len
for (var i = 0; i < howMany; i++) {
value[i] = chars[Math.floor(rnd[i] / d)]
};
return value.join('');
}