fix: ws接收信息ue事件
This commit is contained in:
@@ -18,7 +18,7 @@ export default function useWS() {
|
||||
/**接收数据后回调 */
|
||||
function wsMessage(res: Record<string, any>) {
|
||||
console.log(res);
|
||||
const { code, requestId, groupId, data } = res;
|
||||
const { code, requestId, data } = res;
|
||||
if (code === RESULT_CODE_ERROR) {
|
||||
console.warn(res.msg);
|
||||
return;
|
||||
@@ -44,8 +44,11 @@ export default function useWS() {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!data?.groupId) {
|
||||
return;
|
||||
}
|
||||
// 订阅组信息
|
||||
switch (groupId) {
|
||||
switch (data.groupId) {
|
||||
// ueEvent UE会话事件
|
||||
case '1010':
|
||||
if (data.data) {
|
||||
@@ -76,17 +79,19 @@ export default function useWS() {
|
||||
|
||||
/**ueEvent UE会话事件 数据解析 */
|
||||
function ueEventParse(item: Record<string, any>) {
|
||||
let evData: Record<string, any> = {};
|
||||
try {
|
||||
evData = JSON.parse(item.eventJSON);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return false;
|
||||
let evData: Record<string, any> = item.eventJSON;
|
||||
if (typeof evData === 'string') {
|
||||
try {
|
||||
evData = JSON.parse(item.eventJSON);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (Reflect.has(evData, 'authTime')) {
|
||||
if (item.eventType === 'auth-result') {
|
||||
return {
|
||||
id: item.id,
|
||||
id: item.id || item.timestamp,
|
||||
type: item.eventType,
|
||||
time: evData.authTime,
|
||||
imsi: evData.imsi,
|
||||
@@ -94,9 +99,9 @@ export default function useWS() {
|
||||
};
|
||||
}
|
||||
|
||||
if (Reflect.has(evData, 'detachTime')) {
|
||||
if (item.eventType === 'detach') {
|
||||
return {
|
||||
id: item.id,
|
||||
id: item.id || item.timestamp,
|
||||
type: item.eventType,
|
||||
time: evData.detachTime,
|
||||
imsi: evData.imsi,
|
||||
@@ -104,9 +109,9 @@ export default function useWS() {
|
||||
};
|
||||
}
|
||||
|
||||
if (Reflect.has(evData, 'changeTime')) {
|
||||
if (item.eventType === 'cm-state') {
|
||||
return {
|
||||
id: item.id,
|
||||
id: item.id || item.timestamp,
|
||||
type: item.eventType,
|
||||
time: evData.changeTime,
|
||||
imsi: evData.imsi,
|
||||
|
||||
Reference in New Issue
Block a user