LINXD-2222: Update

This commit is contained in:
Sergiu Toma 2022-09-19 17:40:57 +03:00
parent a59cbcf8cc
commit 40c03592df
2 changed files with 25 additions and 13 deletions

37
app.js
View File

@ -1,24 +1,35 @@
import 'dotenv/config'
/** /**
* integrating mediasoup server with a node.js application * integrating mediasoup server with a node.js application
*/ */
require('dotenv').config()
const app = require('express')();
const https = require('https');
const path = require('node:path');
const __dirname = path.resolve()
let https;
try {
https = require('node:https');
} catch (err) {
console.log('https support is disabled!');
}
const mediasoup = require('mediasoup');
/* Please follow mediasoup installation requirements */ /* Please follow mediasoup installation requirements */
/* 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')(); // const app = require('express')();
// import https from 'httpolyglot' // import https from 'httpolyglot'
import https from "https"; // import https from "https";
import fs from 'fs' // import fs from 'fs'
import path from 'path' // import path from 'path'
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 * as https from "http";
import Server from "socket.io"; // import Server from "socket.io";
// import middleware from 'socketio-wildcard' // import middleware from 'socketio-wildcard'
// const app = express.default(); // const app = express.default();
@ -55,8 +66,10 @@ 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(httpsServer, { allowEIO3: true });
const server = https.createServer(app);
const io = require('socket.io')(server, options);
// const io = new Server(server, { origins: '*:*', allowEIO3: true }); // const io = new Server(server, { origins: '*:*', allowEIO3: true });
// io.use(middleware); // io.use(middleware);

View File

@ -12,7 +12,6 @@
"keywords": [], "keywords": [],
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"type": "module",
"dependencies": { "dependencies": {
"@types/express": "^4.17.13", "@types/express": "^4.17.13",
"dotenv": "^16.0.1", "dotenv": "^16.0.1",