Skip to content

Commit 66377cf

Browse files
committed
refactor: cleanup actions
1 parent a4efbb1 commit 66377cf

File tree

6 files changed

+18
-20
lines changed

6 files changed

+18
-20
lines changed

GUI/ETVR/src/pages/Home/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import icons from '@assets/images'
33
import Camera from '@components/Camera'
44
import List from '@components/List/List'
55
import ListHeader from '@components/List/ListHeader/ListHeader'
6-
import CustomPopover from '@components/header/CustomPopover/index'
6+
import CustomPopover from '@components/Header/CustomPopover'
77
import { POPOVER_ID } from '@src/static/types/enums'
88
import { setRestDevice } from '@src/store/api/restAPI'
99
import { cameras } from '@src/store/camera/selectors'

GUI/ETVR/src/store/api/components/actions.ts

-14
This file was deleted.

GUI/ETVR/src/store/api/websocket.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,10 @@ export const setRTCTimeout = (time: number) => {
7575
}
7676

7777
/**
78-
* @description Generate websocket clients based on the number of cameras connected
78+
* @description Sets the websocket clients
7979
* @returns {void}
8080
* @example
81-
* generateWebsocketClients()
82-
* // => [WebSocket, WebSocket, WebSocket]
81+
* setWebsocketClients([new WebSocket('ws://localhost:8080'), new WebSocket('ws://localhost:8080')])
8382
* @note This function should be called after the cameras have been initialized
8483
*/
8584
export const setWebsocketClients = (clients: WebSocket[]): void => {

GUI/ETVR/src/utils/actions/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { invoke } from '@tauri-apps/api/tauri'
22
import { appWindow } from '@tauri-apps/api/window'
3-
import { generateWebsocketClients } from '@store/api/components/actions'
43
import { setWebsocketClients } from '@store/api/websocket'
4+
import { generateWebsocketClients } from '@utils/hooks/websocket'
55

66
const handleTitlebar = () => {
77
const titlebar = document.getElementsByClassName('titlebar')

GUI/ETVR/src/utils/hooks/websocket/index.ts

+14-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ import { RTCState } from '@src/static/types/enums'
22
import { rtcWebSocket, rtcTimeout, rtcConnectInterval } from '@store/api/selectors'
33
import { setRTCStatus, setConnectInterval, setRTCTimeout } from '@store/api/websocket'
44

5+
import { cameras } from '@store/camera/selectors'
6+
7+
const PORT = 7856
8+
const LOCAL_HOST = 'wss://127.0.0.1'
9+
510
interface IWebRTCMessage {
611
msg: string | object | null | undefined
712
}
@@ -27,6 +32,14 @@ export const check = () => {
2732
})
2833
}
2934

35+
const generateWebsocketClients = () => {
36+
const clients = cameras().map((_, i) => {
37+
return new WebSocket(`${LOCAL_HOST}:${PORT}/camera_${i + 1}`)
38+
})
39+
console.log('websocket clients', clients)
40+
return clients
41+
}
42+
3043
/********************************* connect *************************************/
3144
/**
3245
* @description initialize connection to the server
@@ -85,4 +98,4 @@ const initWebSocket = () => {
8598
})
8699
}
87100

88-
export { sendToRTCServer, initWebSocket }
101+
export { sendToRTCServer, initWebSocket, generateWebsocketClients }

0 commit comments

Comments
 (0)