diff --git a/app.js b/app.js index 8b9e407..13380de 100644 --- a/app.js +++ b/app.js @@ -6,16 +6,22 @@ import 'dotenv/config' /* Please follow mediasoup installation requirements */ /* https://mediasoup.org/documentation/v3/mediasoup/installation/ */ -import express from 'express' -const app = express() - -import https from 'httpolyglot' +// import express from 'express' +// const app = express() +// const app = require('express')(); +// import https from 'httpolyglot' import fs from 'fs' import path from 'path' const __dirname = path.resolve() -import Server from 'socket.io' +// import Server from 'socket.io' import mediasoup from 'mediasoup' +import * as express from "express"; +import * as https from "http"; +import Server from "socket.io"; +import middleware from 'socketio-wildcard' +var middleware = require('socketio-wildcard')(); +const app = express.default(); let worker /** @@ -50,15 +56,19 @@ const options = { cert: fs.readFileSync('./server/ssl/cert.pem', 'utf-8') } -const httpsServer = https.createServer(options, app) +const server = https.createServer(options, app); +const io = new Server(server, { origins: '*:*', allowEIO3: true }); -httpsServer.listen(process.env.PORT, () => { - console.log('Listening on port:', process.env.PORT) -}) +io.use(middleware); +// const httpsServer = https.createServer(options, app) -const io = new Server(httpsServer, { - allowEIO3: true -}); +// httpsServer.listen(process.env.PORT, () => { +// console.log('Listening on port:', process.env.PORT) +// }) + +// const io = new Server(httpsServer, { +// allowEIO3: true +// }); // socket.io namespace (could represent a room?) const peers = io.of('/mediasoup') diff --git a/package-lock.json b/package-lock.json index 59ffca5..2fc7cbf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,8 @@ "mediasoup-client": "^3.6.54", "parcel": "^2.7.0", "socket.io": "^2.0.3", - "socket.io-client": "^2.0.3" + "socket.io-client": "^2.0.3", + "socketio-wildcard": "^2.0.0" }, "devDependencies": { "nodemon": "^2.0.19", @@ -7117,6 +7118,11 @@ "ms": "2.0.0" } }, + "node_modules/socketio-wildcard": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/socketio-wildcard/-/socketio-wildcard-2.0.0.tgz", + "integrity": "sha512-Bf3ioZq15Z2yhFLDasRvbYitg82rwm+5AuER5kQvEQHhNFf4R4K5o/h57nEpN7A59T9FyRtTj34HZfMWAruw/A==" + }, "node_modules/socks": { "version": "2.7.0", "resolved": "https://registry.npmjs.org/socks/-/socks-2.7.0.tgz", @@ -13522,6 +13528,11 @@ } } }, + "socketio-wildcard": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/socketio-wildcard/-/socketio-wildcard-2.0.0.tgz", + "integrity": "sha512-Bf3ioZq15Z2yhFLDasRvbYitg82rwm+5AuER5kQvEQHhNFf4R4K5o/h57nEpN7A59T9FyRtTj34HZfMWAruw/A==" + }, "socks": { "version": "2.7.0", "resolved": "https://registry.npmjs.org/socks/-/socks-2.7.0.tgz", diff --git a/package.json b/package.json index 79fd9b8..00e007c 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,8 @@ "mediasoup-client": "^3.6.54", "parcel": "^2.7.0", "socket.io": "^2.0.3", - "socket.io-client": "^2.0.3" + "socket.io-client": "^2.0.3", + "socketio-wildcard": "^2.0.0" }, "devDependencies": { "nodemon": "^2.0.19",