feat(wsClient): Update WebSocket connection to support relative paths and enhance MQTT handling

This commit is contained in:
Tran Anh Tuan
2026-01-27 12:55:01 +07:00
parent 6d1c085ff7
commit ed5751002b
3 changed files with 17 additions and 14 deletions

View File

@@ -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);