feat: refactor Socket.IO server implementation and update README for queue system
This commit is contained in:
11
app/page.tsx
11
app/page.tsx
@@ -15,11 +15,12 @@ export default function Home() {
|
||||
useEffect(() => {
|
||||
let mounted = true;
|
||||
// dynamic import to avoid bundling issues on server
|
||||
import("socket.io-client").then(({ io }) => {
|
||||
if (!mounted) return;
|
||||
// default to the same origin and connect to the Next.js API route at /api/socket
|
||||
const serverUrl = process.env.NEXT_PUBLIC_SOCKET_URL || window.location.origin;
|
||||
const socket = io(serverUrl, { autoConnect: true, path: "/api/socket" });
|
||||
import("socket.io-client").then(({ io }) => {
|
||||
if (!mounted) return;
|
||||
const socket = io({
|
||||
path: "/api/socket",
|
||||
autoConnect: true
|
||||
});
|
||||
socketRef.current = socket;
|
||||
|
||||
socket.on("connect", () => {
|
||||
|
||||
Reference in New Issue
Block a user