Dev #8
@@ -1135,7 +1135,6 @@ const globalSubscribedRooms = new Set<string>();
|
||||
function notifyRealtimeStatusChange(connected: boolean, transport: RealtimeTransport) {
|
||||
isRealtimeConnectedState = connected;
|
||||
activeTransport = transport;
|
||||
console.log(`[MindSift Realtime] Verbindungsstatus geändert: connected=${connected}, transport=${transport}`);
|
||||
realtimeStatusListeners.forEach((fn) => {
|
||||
try {
|
||||
fn(connected, transport);
|
||||
@@ -1180,17 +1179,14 @@ export function connectSSE(rooms?: string[]): void {
|
||||
|
||||
try {
|
||||
const url = buildSSEURL(undefined, undefined, Array.from(globalSubscribedRooms));
|
||||
console.log(`[MindSift Realtime] Verbinde SSE zu ${url}...`);
|
||||
const es = new EventSource(url);
|
||||
activeGlobalSSE = es;
|
||||
|
||||
es.onopen = () => {
|
||||
console.info('[MindSift Realtime] Server-Sent Events (SSE) erfolgreich verbunden (Corporate Fallback aktiv).');
|
||||
sseReconnectDelay = 2000;
|
||||
notifyRealtimeStatusChange(true, 'sse');
|
||||
if (activeSSEId && globalSubscribedRooms.size > 0) {
|
||||
globalSubscribedRooms.forEach((room) => {
|
||||
console.log(`[MindSift Realtime] SSE Rejoin Room "${room}"`);
|
||||
api.joinSSERoom(activeSSEId!, room, 'join').catch(() => {});
|
||||
});
|
||||
}
|
||||
@@ -1199,13 +1195,10 @@ export function connectSSE(rooms?: string[]): void {
|
||||
es.onmessage = (event) => {
|
||||
try {
|
||||
const msg = JSON.parse(event.data) as WSMessage;
|
||||
console.log('[MindSift Realtime Event] [SSE]', msg.event, msg.payload);
|
||||
if (msg.event === 'SSE_CONNECTED') {
|
||||
activeSSEId = msg.payload?.sseId || null;
|
||||
console.log('[MindSift Realtime] SSE-Client registriert mit ID:', activeSSEId);
|
||||
if (activeSSEId && globalSubscribedRooms.size > 0) {
|
||||
globalSubscribedRooms.forEach((room) => {
|
||||
console.log(`[MindSift Realtime] Trete Raum per SSE bei: "${room}"`);
|
||||
api.joinSSERoom(activeSSEId!, room, 'join').catch(() => {});
|
||||
});
|
||||
}
|
||||
@@ -1254,7 +1247,6 @@ export function connectWebSocket(): void {
|
||||
|
||||
// If proxy blocked WebSocket previously, do not attempt failing WebSocket; stay on SSE
|
||||
if (isWsBlockedByProxy) {
|
||||
console.info('[MindSift Realtime] WebSocket im Firmennetzwerk blockiert (Cache aktiv). Verwende direkt SSE.');
|
||||
connectSSE();
|
||||
return;
|
||||
}
|
||||
@@ -1269,7 +1261,6 @@ export function connectWebSocket(): void {
|
||||
|
||||
try {
|
||||
const url = buildWebSocketURL();
|
||||
console.log(`[MindSift Realtime] Versuche WebSocket-Verbindung zu ${url}...`);
|
||||
const ws = new WebSocket(url);
|
||||
activeGlobalWS = ws;
|
||||
|
||||
@@ -1282,7 +1273,6 @@ export function connectWebSocket(): void {
|
||||
|
||||
ws.onopen = () => {
|
||||
clearTimeout(wsConnectionWatchdog);
|
||||
console.info('[MindSift Realtime] WebSocket erfolgreich verbunden!');
|
||||
if (activeGlobalSSE) {
|
||||
try { activeGlobalSSE.close(); } catch {}
|
||||
activeGlobalSSE = null;
|
||||
@@ -1292,7 +1282,6 @@ export function connectWebSocket(): void {
|
||||
if (globalSubscribedRooms.size > 0) {
|
||||
globalSubscribedRooms.forEach((room) => {
|
||||
try {
|
||||
console.log(`[MindSift Realtime] Trete Raum per WS bei: "${room}"`);
|
||||
ws.send(JSON.stringify({ event: 'JOIN_ROOM', room }));
|
||||
} catch {}
|
||||
});
|
||||
@@ -1302,7 +1291,6 @@ export function connectWebSocket(): void {
|
||||
ws.onmessage = (event) => {
|
||||
try {
|
||||
const msg = JSON.parse(event.data) as WSMessage;
|
||||
console.log('[MindSift Realtime Event] [WS]', msg.event, msg.payload);
|
||||
wsListeners.forEach((fn) => {
|
||||
try {
|
||||
fn(msg);
|
||||
|
||||
Reference in new issue
Block a user