|
@@ -6,7 +6,6 @@ export function useWebSocket() {
|
|
|
const token: any = localStorage.getItem('token');
|
|
|
const deviceid: any = localStorage.getItem('deviceid');
|
|
|
const myToken: any = 'JWT ' + token;
|
|
|
- const ctrlName: any = `facecontroller_${deviceid}`
|
|
|
|
|
|
let socketFace: any = null; //ws实例对象
|
|
|
socketFace = io(address + '/', {
|
|
@@ -27,6 +26,9 @@ export function useWebSocket() {
|
|
|
socketFace.on('my_response', (e: any) => {
|
|
|
callback(e);
|
|
|
});
|
|
|
+ socketFace.on('fe_device_init_result', (e: any) => {
|
|
|
+ callback(e);
|
|
|
+ });
|
|
|
socketFace.on('facecontroller_ack', (e: any) => {
|
|
|
callback(e);
|
|
|
});
|
|
@@ -48,6 +50,19 @@ export function useWebSocket() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 开始连接设备信息
|
|
|
+ */
|
|
|
+ function startDevice(data?: any, callback?: any) {
|
|
|
+ sendMessage(
|
|
|
+ 'fe_device_init',
|
|
|
+ {
|
|
|
+ data: data
|
|
|
+ },
|
|
|
+ () => {}
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 查看人脸识别模块是否可用
|
|
|
*/
|
|
@@ -56,7 +71,7 @@ export function useWebSocket() {
|
|
|
'facecontroller_ack',
|
|
|
{
|
|
|
cmd: 'check_facecontroller_available',
|
|
|
- ctrl_name: ctrlName,
|
|
|
+ ctrl_name: `facecontroller_${data}`
|
|
|
},
|
|
|
() => {}
|
|
|
);
|
|
@@ -70,7 +85,7 @@ export function useWebSocket() {
|
|
|
'facecontroller_ack',
|
|
|
{
|
|
|
cmd: 'open_facecontroller',
|
|
|
- ctrl_name: ctrlName,
|
|
|
+ ctrl_name: `facecontroller_${data}`
|
|
|
},
|
|
|
() => {}
|
|
|
);
|
|
@@ -84,7 +99,7 @@ export function useWebSocket() {
|
|
|
'facecontroller_ack',
|
|
|
{
|
|
|
cmd: 'terminate_facecontroller',
|
|
|
- ctrl_name: ctrlName,
|
|
|
+ ctrl_name: `facecontroller_${data}`
|
|
|
},
|
|
|
() => {}
|
|
|
);
|
|
@@ -98,7 +113,7 @@ export function useWebSocket() {
|
|
|
'facecontroller_ack',
|
|
|
{
|
|
|
cmd: 'suspend_facecontroller',
|
|
|
- ctrl_name: ctrlName,
|
|
|
+ ctrl_name: `facecontroller_${data}`
|
|
|
},
|
|
|
() => {}
|
|
|
);
|
|
@@ -112,7 +127,7 @@ export function useWebSocket() {
|
|
|
'facecontroller_ack',
|
|
|
{
|
|
|
cmd: 'resume_facecontroller',
|
|
|
- ctrl_name: ctrlName,
|
|
|
+ ctrl_name: `facecontroller_${data}`
|
|
|
},
|
|
|
() => {}
|
|
|
);
|
|
@@ -126,7 +141,7 @@ export function useWebSocket() {
|
|
|
'facecontroller_ack',
|
|
|
{
|
|
|
cmd: 'get_facecontroller_state',
|
|
|
- ctrl_name: ctrlName,
|
|
|
+ ctrl_name: `facecontroller_${data}`
|
|
|
},
|
|
|
() => {}
|
|
|
);
|
|
@@ -139,5 +154,5 @@ export function useWebSocket() {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- return { faceWs, sendMessage, checkFace, openFace, terminateFace, suspendFace, resumeFace, getFace };
|
|
|
+ return { faceWs,startDevice, sendMessage, checkFace, openFace, terminateFace, suspendFace, resumeFace, getFace };
|
|
|
}
|