* build endpoint to get asset count by month * Added asset repository * Added create asset * get asset by device ID * Added test for existing methods * Refactor additional endpoint * Refactor database api to get curated locations and curated objects * Refactor get search properties * Fixed cookies parsing for websocket * Added API to get asset count by time group * Remove unused code
32 lines
613 B
TypeScript
32 lines
613 B
TypeScript
import { Socket, io } 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
|
|
});
|
|
|
|
listenToEvent(websocket);
|
|
} catch (e) {
|
|
console.log('Cannot connect to websocket ', e);
|
|
}
|
|
};
|
|
|
|
const listenToEvent = (socket: Socket) => {
|
|
socket.on('on_upload_success', (data) => {});
|
|
|
|
socket.on('error', (e) => {
|
|
console.log('Websocket Error', e);
|
|
});
|
|
};
|
|
|
|
export const closeWebsocketConnection = () => {
|
|
websocket?.close();
|
|
};
|