caelum0x f80b04ae0f feat(ritgram): move GitGram app into railyard as Ritgram, next to Rithub
Moved later/gitgram-ai/gitgram/ to apps/ritgram/ (fresh history; full history stays in caelum0x/gitgram).
AITimeMachine stays separate in later/gitgram-ai per the Rithub master plan.
Logs, pid files and env files are ignored; GPL-3.0 mobile/proximity noted in THIRD_PARTY_NOTICES.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-11-13 04:18:46 +03:00

52 lines
976 B
TypeScript

import { io, Socket } from 'socket.io-client';
import { SOCKET_URL } from '../constants/Config';
import { useAuthStore } from '../store/authStore';
import { logger } from '../utils/logger';
let socket: Socket | null = null;
export const initializeSocket = (): Socket | null => {
const { accessToken } = useAuthStore.getState();
if (!accessToken) {
return null;
}
if (socket?.connected) {
return socket;
}
socket = io(SOCKET_URL, {
auth: {
token: accessToken,
},
transports: ['websocket'],
});
socket.on('connect', () => {
logger.log('Socket connected');
});
socket.on('disconnect', () => {
logger.log('Socket disconnected');
});
socket.on('error', (error) => {
logger.error('Socket error:', error);
});
return socket;
};
export const disconnectSocket = () => {
if (socket) {
socket.disconnect();
socket = null;
}
};
export const getSocket = (): Socket | null => {
return socket;
};