join.ts 629 B

12345678910111213141516171819202122232425
  1. import { getApp } from "/@/hooks/userApp";
  2. import { useRoom } from "/@/hooks/useRoom";
  3. import { useSocket } from "/@/hooks/userSocket";
  4. import { useRtcStore } from "/@/store/modules/rtc";
  5. const { enterRoom } = useRoom()
  6. // 自已join的方法
  7. export function handleJoin(data: any) {
  8. const app = getApp();
  9. const socket = useSocket()
  10. enterRoom();
  11. const rtcStore = useRtcStore();
  12. rtcStore.setIsJoined(true)
  13. //
  14. if (!rtcStore.isLeader) {
  15. setTimeout(() => {
  16. socket.emit("action", {
  17. type: "user-init",
  18. });
  19. }, 1500);
  20. }
  21. }