LINXD-2222: Update

This commit is contained in:
Sergiu Toma 2022-09-19 17:03:58 +03:00
parent f6d862966e
commit 9c731f4085

30
app.js
View File

@ -8,14 +8,19 @@ import 'dotenv/config'
/* https://mediasoup.org/documentation/v3/mediasoup/installation/ */ /* https://mediasoup.org/documentation/v3/mediasoup/installation/ */
import express from 'express' import express from 'express'
const app = express() const app = express()
// const app = require('express')();
import https from 'httpolyglot' // import https from 'httpolyglot'
import * as https from "http";
import fs from 'fs' import fs from 'fs'
import path from 'path' import path from 'path'
const __dirname = path.resolve() const __dirname = path.resolve()
import Server from 'socket.io' // import Server from 'socket.io'
import mediasoup from 'mediasoup' import mediasoup from 'mediasoup'
// import * as https from "http";
import Server from "socket.io";
// import middleware from 'socketio-wildcard'
// const app = express.default();
let worker let worker
/** /**
@ -50,15 +55,20 @@ const options = {
cert: fs.readFileSync('./server/ssl/cert.pem', 'utf-8') cert: fs.readFileSync('./server/ssl/cert.pem', 'utf-8')
} }
const httpsServer = https.createServer(options, app) const httpsServer = https.createServer(options, app);
const io = new Server(httpsServer, { allowEIO3: true });
// const io = new Server(server, { origins: '*:*', allowEIO3: true });
httpsServer.listen(process.env.PORT, () => { // io.use(middleware);
console.log('Listening on port:', process.env.PORT) // const httpsServer = https.createServer(options, app)
})
const io = new Server(httpsServer, { // httpsServer.listen(process.env.PORT, () => {
allowEIO3: true // console.log('Listening on port:', process.env.PORT)
}); // })
// const io = new Server(httpsServer, {
// allowEIO3: true
// });
// socket.io namespace (could represent a room?) // socket.io namespace (could represent a room?)
const peers = io.of('/mediasoup') const peers = io.of('/mediasoup')