feat: Dynamically fetch TURN credentials, improve WebRTC connection stability with ICE restart logic, and configure TURN via environment variables.

This commit is contained in:
2026-02-23 05:55:25 +01:00
parent deab4dd4a0
commit 26decc2c3c
4 changed files with 90 additions and 15 deletions

View File

@@ -7,8 +7,15 @@ const io = new Server(server);
// Password setting via environment variable, defaulting to "secret"
const BROADCASTER_PASSWORD = process.env.BROADCASTER_PASSWORD;
const TURN_USER = process.env.TURN_USER || 'myuser';
const TURN_PASSWORD = process.env.TURN_PASSWORD || 'mypassword';
let broadcasterSocketId = null;
// Serve TURN credentials to clients
app.get('/turn-config', (req, res) => {
res.json({ username: TURN_USER, credential: TURN_PASSWORD });
});
app.use(express.static("public"));
io.on("connection", (socket) => {