Pārlūkot izejas kodu

用户通话邀请

warrior 4 mēneši atpakaļ
vecāks
revīzija
903e7c194a

+ 7 - 1
projects/live-app/src/services/auth.service.ts

@@ -2,13 +2,18 @@ import { Injectable } from '@angular/core';
 import * as Parse from 'parse';
 import { Router } from '@angular/router';
 import { MessageService } from './message.service';
+import { ConnectTaskService } from './connectTask.service';
 @Injectable({
   providedIn: 'root',
 })
 export class AuthService {
   company: string = 'Qje9D4bqol';
   redirectUrl: string = 'tabs';
-  constructor(private router: Router, private msgSer: MessageService) {}
+  constructor(
+    private connectTask: ConnectTaskService,
+    private router: Router,
+    private msgSer: MessageService
+  ) {}
   authMobile(
     mobile: string,
     password?: string,
@@ -59,6 +64,7 @@ export class AuthService {
     localStorage.clear(); // 清楚过期登录状态,重新登陆
     Parse.User.logOut().then((user) => {
       this.msgSer.logOutRTM();
+      this.connectTask.reset()
       this.router.navigate(['login']);
     });
   }

+ 6 - 1
projects/live-app/src/services/connectTask.service.ts

@@ -8,6 +8,7 @@ export class ConnectTaskService {
   anchorChannelName?: string;
   msChannelName: string = 'user_connect_room'; // 主播在线上报频道
   onlineUserList: Array<string> = []; // 在线用户列表
+  isSubscribe: boolean = false;
   constructor(private msgSer: MessageService) {}
 
   async init() {
@@ -16,11 +17,15 @@ export class ConnectTaskService {
     await this.anchorOnline();
     this.getOnlieUserList(this.msChannelName, 'MESSAGE');
   }
+  reset(){
+    this.onlineUserList = [];
+    this.isSubscribe = false;
+  }
   /* 主播上线 */
   async anchorOnline() {
     let profile = JSON.parse(localStorage.getItem('profile') || '');
     const uid = Parse.User.current()?.id!;
-    if (profile?.identyType == 'anchor') {
+    if (profile?.identyType == 'anchor' && !this.isSubscribe) {
       let nowChannes = await this.getWhereNow(uid);
       console.log('用户已订阅频道:', nowChannes);
       // if (!nowChannes.includes(this.msChannelName)) {