LINXD-2222: Set namespate to '/'; Removed httpolyglot; Removed unused code

This commit is contained in:
2022-09-20 14:02:22 +03:00
parent 149876fc70
commit be396e1047
3 changed files with 6 additions and 38 deletions

29
app.js
View File

@ -1,7 +1,3 @@
/**
* integrating mediasoup server with a node.js application
*/
require('dotenv').config()
const express = require('express');
@ -9,14 +5,12 @@ const app = express();
const Server = require('socket.io');
const path = require('node:path');
const fs = require('node:fs');
// const httpolyglot = require('httpolyglot');
let https = require('https');
try {
https = require('node:https');
} catch (err) {
console.log('https support is disabled!');
}
const mediasoup = require('mediasoup');
let worker
@ -55,33 +49,22 @@ const options = {
}
const httpsServer = https.createServer(options, app);
// const io = new Server(httpsServer, { allowEIO3: true });
// const httpsServer = httpolyglot.createServer(options, app);
const io = new Server(httpsServer, {
allowEIO3: true,
origins: ["*:*"],
allowRequest: (req, next) => {
console.log('req', req);
next(null, true)
}
// allowRequest: (req, next) => {
// console.log('req', req);
// next(null, true)
// }
});
// const io = new Server(server, { origins: '*:*', allowEIO3: true });
httpsServer.listen(process.env.PORT, () => {
console.log('Listening on port:', process.env.PORT)
console.log('Video server listening on port:', process.env.PORT)
})
// io.use(middleware);
// const httpsServer = https.createServer(options, app)
// const io = new Server(httpsServer, {
// allowEIO3: true
// });
// socket.io namespace (could represent a room?)
const peers = io.of('/mediasoup')
const peers = io.of('/')
const createWorker = async () => {
worker = await mediasoup.createWorker({