Commit 66377cf 1 parent a4efbb1 commit 66377cf Copy full SHA for 66377cf
File tree 6 files changed +18
-20
lines changed
6 files changed +18
-20
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import icons from '@assets/images'
3
3
import Camera from '@components/Camera'
4
4
import List from '@components/List/List'
5
5
import ListHeader from '@components/List/ListHeader/ListHeader'
6
- import CustomPopover from '@components/header /CustomPopover/index '
6
+ import CustomPopover from '@components/Header /CustomPopover'
7
7
import { POPOVER_ID } from '@src/static/types/enums'
8
8
import { setRestDevice } from '@src/store/api/restAPI'
9
9
import { cameras } from '@src/store/camera/selectors'
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -75,11 +75,10 @@ export const setRTCTimeout = (time: number) => {
75
75
}
76
76
77
77
/**
78
- * @description Generate websocket clients based on the number of cameras connected
78
+ * @description Sets the websocket clients
79
79
* @returns {void }
80
80
* @example
81
- * generateWebsocketClients()
82
- * // => [WebSocket, WebSocket, WebSocket]
81
+ * setWebsocketClients([new WebSocket('ws://localhost:8080'), new WebSocket('ws://localhost:8080')])
83
82
* @note This function should be called after the cameras have been initialized
84
83
*/
85
84
export const setWebsocketClients = ( clients : WebSocket [ ] ) : void => {
Original file line number Diff line number Diff line change 1
1
import { invoke } from '@tauri-apps/api/tauri'
2
2
import { appWindow } from '@tauri-apps/api/window'
3
- import { generateWebsocketClients } from '@store/api/components/actions'
4
3
import { setWebsocketClients } from '@store/api/websocket'
4
+ import { generateWebsocketClients } from '@utils/hooks/websocket'
5
5
6
6
const handleTitlebar = ( ) => {
7
7
const titlebar = document . getElementsByClassName ( 'titlebar' )
File renamed without changes.
Original file line number Diff line number Diff line change @@ -2,6 +2,11 @@ import { RTCState } from '@src/static/types/enums'
2
2
import { rtcWebSocket , rtcTimeout , rtcConnectInterval } from '@store/api/selectors'
3
3
import { setRTCStatus , setConnectInterval , setRTCTimeout } from '@store/api/websocket'
4
4
5
+ import { cameras } from '@store/camera/selectors'
6
+
7
+ const PORT = 7856
8
+ const LOCAL_HOST = 'wss://127.0.0.1'
9
+
5
10
interface IWebRTCMessage {
6
11
msg : string | object | null | undefined
7
12
}
@@ -27,6 +32,14 @@ export const check = () => {
27
32
} )
28
33
}
29
34
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
+
30
43
/********************************* connect *************************************/
31
44
/**
32
45
* @description initialize connection to the server
@@ -85,4 +98,4 @@ const initWebSocket = () => {
85
98
} )
86
99
}
87
100
88
- export { sendToRTCServer , initWebSocket }
101
+ export { sendToRTCServer , initWebSocket , generateWebsocketClients }
You can’t perform that action at this time.
0 commit comments