feat(wsClient): Update WebSocket connection to support relative paths and enhance MQTT handling
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { apiSearchThings } from '@/services/master/ThingController';
|
||||
import { apiGetThingDetail } from '@/services/master/ThingController';
|
||||
import { wsClient } from '@/utils/wsClient';
|
||||
import {
|
||||
ArrowLeftOutlined,
|
||||
@@ -111,7 +111,7 @@ const CameraConfigPage = () => {
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
wsClient.connect('wss://gms.smatec.com.vn/mqtt', false);
|
||||
wsClient.connect('/mqtt', false);
|
||||
const unsubscribe = wsClient.subscribe((data: any) => {
|
||||
console.log('Received WS data:', data);
|
||||
});
|
||||
@@ -126,16 +126,8 @@ const CameraConfigPage = () => {
|
||||
if (!thingId) return;
|
||||
try {
|
||||
setLoading(true);
|
||||
const response = await apiSearchThings({
|
||||
offset: 0,
|
||||
limit: 1,
|
||||
id: thingId,
|
||||
});
|
||||
if (response?.things && response.things.length > 0) {
|
||||
setThingName(response.things[0].name || thingId);
|
||||
} else {
|
||||
setThingName(thingId);
|
||||
}
|
||||
const thing = await apiGetThingDetail(thingId);
|
||||
setThingName(thing.name || thingId);
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch thing info:', error);
|
||||
setThingName(thingId);
|
||||
|
||||
Reference in New Issue
Block a user