// 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() { //192.168.0.52:9099/?userId=123 this.socket = io("ws://192.168.0.152:9099", { reconnectionDelayMax: 10000, transports: ["websocket"], query: { userId: "123", roomId: "8888", }, }); 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(callback) { this.startSocket(); console.log("init-trtc"); const config = { sdkAppId: 1400653314, // roomId: "8888", userId: "123", }; const { sdkAppId, roomId, userId } = config; this.socket.on("getSign", async (data) => { const userSig = data; this.userSig = userSig; try { const client = TRTC.createClient({ mode: "rtc", sdkAppId: sdkAppId, userId: userId, userSig, }); this.client = client; // await client.join(); callback(); } catch (error) { console.log("joinRoom error", error); callback(error); } }); } }