migrate from github

This commit is contained in:
2026-07-15 22:49:51 +08:00
commit 81bc0cecbe
30 changed files with 2580 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
const WebSocket = require('ws');
function bindWebSocketGateway({ server, redis, setupWSConnection }) {
const wss = new WebSocket.Server({ server });
wss.on('connection', async (conn, req) => {
const url = new URL(req.url, `http://${req.headers.host}`);
const roomName = url.pathname.slice(1);
if (roomName) {
redis.updateRoomActiveTime(roomName);
}
try {
await setupWSConnection(conn, req, {
gc: true
});
} catch (err) {
console.error('Failed to setup WS connection:', err);
conn.close();
}
});
return wss;
}
module.exports = {
bindWebSocketGateway
};