connection.js 908 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // import { io } from "https://cdn.socket.io/4.4.1/socket.io.esm.min.js";
  2. export class Connection {
  3. constructor(config) {
  4. socket: null;
  5. client: null;
  6. userSig: null;
  7. this.init(config);
  8. }
  9. startSocket(config) {
  10. //192.168.0.52:9099/?userId=123
  11. console.log("init-startSocket");
  12. const { roomId, userId } = config;
  13. this.socket = io("wss://demo-kms.4dage.com", {
  14. reconnectionDelayMax: 10000,
  15. transports: ["websocket"],
  16. query: {
  17. userId: userId,
  18. roomId: roomId,
  19. },
  20. });
  21. this.socket.on("connect", (data) => {
  22. console.log("111", data);
  23. });
  24. this.socket.on("connect_error", (error) => {
  25. console.log("error", error);
  26. });
  27. // setTimeout(() => {
  28. // console.log("this.socket", this.socket);
  29. // }, 3000);
  30. }
  31. init(config) {
  32. console.log("init-trtc",config);
  33. this.startSocket(config);
  34. }
  35. }