2024-10-29 16:47:10 -04:00
|
|
|
import http from "http";
|
|
|
|
|
import { Server, ServerOptions } from "socket.io";
|
2024-11-07 12:39:36 -05:00
|
|
|
import { GlideClient, GlideClientConfiguration } from '@valkey/valkey-glide';
|
2024-10-29 16:47:10 -04:00
|
|
|
|
|
|
|
|
// Import setupWebsocket
|
|
|
|
|
import { setupWebsocket } from "./socket/setupWebSocket";
|
|
|
|
|
|
2024-11-05 16:37:07 -05:00
|
|
|
const port = 4500;
|
2024-10-29 16:47:10 -04:00
|
|
|
|
|
|
|
|
// Create HTTP and WebSocket server
|
|
|
|
|
const server = http.createServer();
|
|
|
|
|
const ioOptions: Partial<ServerOptions> = {
|
|
|
|
|
path: "/socket.io",
|
|
|
|
|
cors: {
|
|
|
|
|
origin: "*",
|
|
|
|
|
methods: ["GET", "POST"],
|
|
|
|
|
credentials: true,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const io = new Server(server, ioOptions);
|
|
|
|
|
|
|
|
|
|
// Initialize WebSocket setup
|
|
|
|
|
setupWebsocket(io);
|
|
|
|
|
|
|
|
|
|
server.listen(port, () => {
|
|
|
|
|
console.log(`WebSocket server is running on port ${port}`);
|
|
|
|
|
});
|