mirror of
https://github.com/KevinMidboe/immich.git
synced 2025-10-29 17:40:28 +00:00
@@ -1,32 +1,32 @@
|
||||
import { Socket, io } from 'socket.io-client';
|
||||
import { io, Socket } from 'socket.io-client';
|
||||
|
||||
let websocket: Socket;
|
||||
|
||||
export const openWebsocketConnection = () => {
|
||||
try {
|
||||
websocket = io('', {
|
||||
path: '/api/socket.io',
|
||||
transports: ['polling'],
|
||||
reconnection: true,
|
||||
forceNew: true,
|
||||
autoConnect: true
|
||||
});
|
||||
try {
|
||||
websocket = io('', {
|
||||
path: '/api/socket.io',
|
||||
transports: ['polling'],
|
||||
reconnection: true,
|
||||
forceNew: true,
|
||||
autoConnect: true,
|
||||
});
|
||||
|
||||
listenToEvent(websocket);
|
||||
} catch (e) {
|
||||
console.log('Cannot connect to websocket ', e);
|
||||
}
|
||||
listenToEvent(websocket);
|
||||
} catch (e) {
|
||||
console.log('Cannot connect to websocket ', e);
|
||||
}
|
||||
};
|
||||
|
||||
const listenToEvent = (socket: Socket) => {
|
||||
//TODO: if we are not using this, we should probably remove it?
|
||||
socket.on('on_upload_success', () => undefined);
|
||||
//TODO: if we are not using this, we should probably remove it?
|
||||
socket.on('on_upload_success', () => undefined);
|
||||
|
||||
socket.on('error', (e) => {
|
||||
console.log('Websocket Error', e);
|
||||
});
|
||||
socket.on('error', (e) => {
|
||||
console.log('Websocket Error', e);
|
||||
});
|
||||
};
|
||||
|
||||
export const closeWebsocketConnection = () => {
|
||||
websocket?.close();
|
||||
websocket?.close();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user