connection.js 998 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 { sceneCode, userId } = config;
  13. const socketUrl ='wss://demo-kms.4dage.com'
  14. // const socketUrl ='ws://192.168.0.152:9099'
  15. this.socket = io(socketUrl, {
  16. reconnectionDelayMax: 10000,
  17. transports: ["websocket"],
  18. query: {
  19. userId: userId,
  20. sceneCode: sceneCode,
  21. },
  22. });
  23. this.socket.on("connect", (data) => {
  24. console.log("111", data);
  25. });
  26. this.socket.on("connect_error", (error) => {
  27. console.log("error", error);
  28. });
  29. // setTimeout(() => {
  30. // console.log("this.socket", this.socket);
  31. // }, 3000);
  32. }
  33. init(config) {
  34. console.log("init-trtc",config);
  35. this.startSocket(config);
  36. }
  37. }