17 lines
342 B
TypeScript
17 lines
342 B
TypeScript
// lib/socketClient.ts
|
|
'use client';
|
|
|
|
import { io, Socket } from 'socket.io-client';
|
|
|
|
let socket: Socket | null = null;
|
|
|
|
export function getSocket(): Socket {
|
|
if (!socket) {
|
|
// Standard: gleiche Origin, /socket.io
|
|
socket = io({
|
|
path: '/api/socketio', // entspricht unserem Server-Endpunkt unten
|
|
});
|
|
}
|
|
return socket;
|
|
}
|