// import { io } from "https://cdn.socket.io/4.4.1/socket.io.esm.min.js"; export class Connection { constructor() { socket: null; client: null; userSig: null; } startSocket(config) { //192.168.0.52:9099/?userId=123 console.log("init-startSocket"); const { sdkAppId, roomId, userId } = config; this.socket = io("wss://demo-kms.4dage.com", { reconnectionDelayMax: 10000, transports: ["websocket"], query: { userId: userId, roomId: roomId, }, }); this.socket.on("connect", (data) => { console.log("111", data); }); this.socket.on("connect_error", (error) => { console.log("error", error); }); // setTimeout(() => { // console.log("this.socket", this.socket); // }, 3000); } async init(config, callback) { console.log("init-trtc"); this.startSocket(config); const { sdkAppId, roomId, userId, role } = config; this.socket.on("getSign", async (data) => { const userSig = data; this.userSig = userSig; try { const client = TRTC.createClient({ mode: "rtc", sdkAppId: sdkAppId, userId: userId, role: role, useStringRoomId: true, userSig, }); this.client = client; callback(); } catch (error) { console.log("joinRoom error", error); callback(error); } }); } }