livekit
This commit is contained in:
31
apps/mediasoup-server/index.ts
Normal file
31
apps/mediasoup-server/index.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import "dotenv/config";
|
||||
import express from "express";
|
||||
import { createServer } from "http";
|
||||
import { Server } from "socket.io";
|
||||
import { createAdapter } from "@socket.io/redis-adapter";
|
||||
import { jwtMiddleware } from "modules/socketJWTmiddleware";
|
||||
import { pubClient, subClient } from "modules/redis";
|
||||
|
||||
const app = express();
|
||||
const server = createServer(app);
|
||||
|
||||
pubClient.keys("dispatchers*").then((keys) => {
|
||||
if (!keys) return;
|
||||
keys.forEach(async (key) => {
|
||||
await pubClient.json.del(key);
|
||||
});
|
||||
});
|
||||
|
||||
const io = new Server(server, {
|
||||
adapter: createAdapter(pubClient, subClient),
|
||||
cors: {},
|
||||
});
|
||||
|
||||
io.use(jwtMiddleware);
|
||||
|
||||
io.on("connection", (socket) => {
|
||||
console.log("User conencted to mediasoup server");
|
||||
});
|
||||
server.listen(process.env.PORT, () => {
|
||||
console.log(`Server running on port ${process.env.PORT}`);
|
||||
});
|
||||
Reference in New Issue
Block a user