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.
|
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).
|
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()
|
||||||
|
|
||||||
/**
|
const express = require('express');
|
||||||
* integrating mediasoup server with a node.js application
|
const app = express();
|
||||||
*/
|
const Server = require('socket.io');
|
||||||
|
const path = require('node:path');
|
||||||
/* Please follow mediasoup installation requirements */
|
const fs = require('node:fs');
|
||||||
/* https://mediasoup.org/documentation/v3/mediasoup/installation/ */
|
let https = require('https');
|
||||||
import express from 'express'
|
try {
|
||||||
const app = express()
|
https = require('node:https');
|
||||||
|
} catch (err) {
|
||||||
import https from 'httpolyglot'
|
console.log('https support is disabled!');
|
||||||
import fs from 'fs'
|
}
|
||||||
import path from 'path'
|
const mediasoup = require('mediasoup');
|
||||||
const __dirname = path.resolve()
|
|
||||||
|
|
||||||
import Server from 'socket.io'
|
|
||||||
import mediasoup from 'mediasoup'
|
|
||||||
|
|
||||||
let worker
|
let worker
|
||||||
/**
|
/**
|
||||||
@ -47,21 +43,26 @@ app.use('/sfu', express.static(path.join(__dirname, 'public')))
|
|||||||
// SSL cert for HTTPS access
|
// SSL cert for HTTPS access
|
||||||
const options = {
|
const options = {
|
||||||
key: fs.readFileSync('./server/ssl/key.pem', 'utf-8'),
|
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)
|
const httpsServer = https.createServer(options, app);
|
||||||
|
|
||||||
httpsServer.listen(process.env.PORT, () => {
|
|
||||||
console.log('Listening on port:', process.env.PORT)
|
|
||||||
})
|
|
||||||
|
|
||||||
const io = new Server(httpsServer, {
|
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?)
|
httpsServer.listen(process.env.PORT, () => {
|
||||||
const peers = io.of('/mediasoup')
|
console.log('Video server listening on port:', process.env.PORT)
|
||||||
|
})
|
||||||
|
|
||||||
|
const peers = io.of('/')
|
||||||
|
|
||||||
const createWorker = async () => {
|
const createWorker = async () => {
|
||||||
worker = await mediasoup.createWorker({
|
worker = await mediasoup.createWorker({
|
||||||
|
14
package-lock.json
generated
14
package-lock.json
generated
@ -12,7 +12,6 @@
|
|||||||
"@types/express": "^4.17.13",
|
"@types/express": "^4.17.13",
|
||||||
"dotenv": "^16.0.1",
|
"dotenv": "^16.0.1",
|
||||||
"express": "^4.18.1",
|
"express": "^4.18.1",
|
||||||
"httpolyglot": "^0.1.2",
|
|
||||||
"mediasoup": "^3.10.4",
|
"mediasoup": "^3.10.4",
|
||||||
"mediasoup-client": "^3.6.54",
|
"mediasoup-client": "^3.6.54",
|
||||||
"parcel": "^2.7.0",
|
"parcel": "^2.7.0",
|
||||||
@ -4603,14 +4602,6 @@
|
|||||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
|
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
|
||||||
"dev": true
|
"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": {
|
"node_modules/https-browserify": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz",
|
"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": {
|
"https-browserify": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz",
|
||||||
|
@ -12,12 +12,10 @@
|
|||||||
"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",
|
||||||
"express": "^4.18.1",
|
"express": "^4.18.1",
|
||||||
"httpolyglot": "^0.1.2",
|
|
||||||
"mediasoup": "^3.10.4",
|
"mediasoup": "^3.10.4",
|
||||||
"mediasoup-client": "^3.6.54",
|
"mediasoup-client": "^3.6.54",
|
||||||
"parcel": "^2.7.0",
|
"parcel": "^2.7.0",
|
||||||
|
Loading…
Reference in New Issue
Block a user