forked from drone/command-center-dashboard

张含笑
2025-04-21 bda33a4e7f08fd133ae8bff8d968143f858c2e6a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import ConnectWebSocket from '@/websocket'
import { getWebsocketUrl } from '@/websocket/util/config'
 
/**
 * 接收一个message函数
 * @param messageHandler
 * @param url
 */
export function useConnectWebSocket(messageHandler, url) {
    const webSocket = new ConnectWebSocket(url || getWebsocketUrl())
 
    webSocket?.registerMessageHandler(messageHandler)
    webSocket?.initSocket()
 
    return webSocket
}