LINXD-2222-debugging-for-i-os #7
2
.env
2
.env
@ -1,3 +1,3 @@
|
||||
PORT=3001
|
||||
PORT=3000
|
||||
IP=0.0.0.0 # Listening IPv4 or IPv6.
|
||||
ANNOUNCED_IP=185.8.154.190 # Announced IPv4 or IPv6 (useful when running mediasoup behind NAT with private IP).
|
||||
|
53
app.js
53
app.js
@ -1,21 +1,17 @@
|
||||
import 'dotenv/config'
|
||||
require('dotenv').config()
|
||||
|
||||
/**
|
||||
* integrating mediasoup server with a node.js application
|
||||
*/
|
||||
|
||||
/* Please follow mediasoup installation requirements */
|
||||
/* https://mediasoup.org/documentation/v3/mediasoup/installation/ */
|
||||
import express from 'express'
|
||||
const app = express()
|
||||
|
||||
import https from 'httpolyglot'
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
const __dirname = path.resolve()
|
||||
|
||||
import Server from 'socket.io'
|
||||
import mediasoup from 'mediasoup'
|
||||
const express = require('express');
|
||||
const app = express();
|
||||
const Server = require('socket.io');
|
||||
const path = require('node:path');
|
||||
const fs = require('node:fs');
|
||||
let https = require('https');
|
||||
try {
|
||||
https = require('node:https');
|
||||
} catch (err) {
|
||||
console.log('https support is disabled!');
|
||||
}
|
||||
const mediasoup = require('mediasoup');
|
||||
|
||||
let worker
|
||||
/**
|
||||
@ -47,21 +43,26 @@ app.use('/sfu', express.static(path.join(__dirname, 'public')))
|
||||
// SSL cert for HTTPS access
|
||||
const options = {
|
||||
key: fs.readFileSync('./server/ssl/key.pem', 'utf-8'),
|
||||
cert: fs.readFileSync('./server/ssl/cert.pem', 'utf-8')
|
||||
cert: fs.readFileSync('./server/ssl/cert.pem', 'utf-8'),
|
||||
}
|
||||
|
||||
const httpsServer = https.createServer(options, app)
|
||||
|
||||
httpsServer.listen(process.env.PORT, () => {
|
||||
console.log('Listening on port:', process.env.PORT)
|
||||
})
|
||||
const httpsServer = https.createServer(options, app);
|
||||
|
||||
const io = new Server(httpsServer, {
|
||||
allowEIO3: true
|
||||
allowEIO3: true,
|
||||
origins: ["*:*"],
|
||||
// allowRequest: (req, next) => {
|
||||
// console.log('req', req);
|
||||
// next(null, true)
|
||||
// }
|
||||
});
|
||||
// const io = new Server(server, { origins: '*:*', allowEIO3: true });
|
||||
|
||||
// socket.io namespace (could represent a room?)
|
||||
const peers = io.of('/mediasoup')
|
||||
httpsServer.listen(process.env.PORT, () => {
|
||||
console.log('Video server listening on port:', process.env.PORT)
|
||||
})
|
||||
|
||||
const peers = io.of('/')
|
||||
|
||||
const createWorker = async () => {
|
||||
worker = await mediasoup.createWorker({
|
||||
|
14
package-lock.json
generated
14
package-lock.json
generated
@ -12,7 +12,6 @@
|
||||
"@types/express": "^4.17.13",
|
||||
"dotenv": "^16.0.1",
|
||||
"express": "^4.18.1",
|
||||
"httpolyglot": "^0.1.2",
|
||||
"mediasoup": "^3.10.4",
|
||||
"mediasoup-client": "^3.6.54",
|
||||
"parcel": "^2.7.0",
|
||||
@ -4603,14 +4602,6 @@
|
||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/httpolyglot": {
|
||||
"version": "0.1.2",
|
||||
"resolved": "https://registry.npmjs.org/httpolyglot/-/httpolyglot-0.1.2.tgz",
|
||||
"integrity": "sha512-ouHI1AaQMLgn4L224527S5+vq6hgvqPteurVfbm7ChViM3He2Wa8KP1Ny7pTYd7QKnDSPKcN8JYfC8r/lmsE3A==",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/https-browserify": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz",
|
||||
@ -11558,11 +11549,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"httpolyglot": {
|
||||
"version": "0.1.2",
|
||||
"resolved": "https://registry.npmjs.org/httpolyglot/-/httpolyglot-0.1.2.tgz",
|
||||
"integrity": "sha512-ouHI1AaQMLgn4L224527S5+vq6hgvqPteurVfbm7ChViM3He2Wa8KP1Ny7pTYd7QKnDSPKcN8JYfC8r/lmsE3A=="
|
||||
},
|
||||
"https-browserify": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz",
|
||||
|
@ -12,12 +12,10 @@
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"@types/express": "^4.17.13",
|
||||
"dotenv": "^16.0.1",
|
||||
"express": "^4.18.1",
|
||||
"httpolyglot": "^0.1.2",
|
||||
"mediasoup": "^3.10.4",
|
||||
"mediasoup-client": "^3.6.54",
|
||||
"parcel": "^2.7.0",
|
||||
|
Loading…
Reference in New Issue
Block a user