|
@@ -23,7 +23,12 @@ export class ConnectTaskService {
|
|
|
}
|
|
|
/* 主播上线 */
|
|
|
async anchorOnline() {
|
|
|
- let profile = JSON.parse(localStorage.getItem('profile') || '');
|
|
|
+ let profile
|
|
|
+ try{
|
|
|
+ profile = JSON.parse(localStorage.getItem('profile') || '');
|
|
|
+ }catch(err){
|
|
|
+ console.log("profile err",err)
|
|
|
+ }
|
|
|
const uid = Parse.User.current()?.id!;
|
|
|
if (profile?.identyType == 'anchor' && !this.isSubscribe) {
|
|
|
let nowChannes = await this.getWhereNow(uid);
|
|
@@ -100,25 +105,29 @@ export class ConnectTaskService {
|
|
|
};
|
|
|
if (page) options.page = page;
|
|
|
try {
|
|
|
- const result = await this.msgSer.rtmClient.presence.whoNow(
|
|
|
+ const result = await this.msgSer?.rtmClient?.presence?.whoNow(
|
|
|
channelName,
|
|
|
channelType ?? 'MESSAGE',
|
|
|
options
|
|
|
);
|
|
|
// console.log(result);
|
|
|
// 如果 nextPage 存在,下一次调用 whoNow 时,需将 nextPage 的值填入 whoNowOptions 的 page 字段
|
|
|
- const { totalOccupancy, occupants, nextPage } = result;
|
|
|
- occupants.forEach((userInfo: any) => {
|
|
|
+
|
|
|
+ let totalOccupancy = result?.totalOccupancy
|
|
|
+ let occupants = result?.occupants
|
|
|
+ let nextPage = result?.nextPage
|
|
|
+ occupants?.forEach((userInfo: any) => {
|
|
|
const { states, userId, statesCount } = userInfo;
|
|
|
this.onlineUserList.add(userId);
|
|
|
});
|
|
|
console.log('获取在线用户列表:',this.onlineUserList);
|
|
|
if (nextPage) this.getOnlieUserList(channelName, nextPage, channelType);
|
|
|
} catch (status: any) {
|
|
|
- const { operation, reason, errorCode } = status;
|
|
|
- console.error(
|
|
|
- `${operation} failed, ErrorCode: ${errorCode}, due to: ${reason}.`
|
|
|
- );
|
|
|
+ // const { operation, reason, errorCode } = status;
|
|
|
+ console.error("getOnlieUserList err",status)
|
|
|
+ // console.error(
|
|
|
+ // `${operation} failed, ErrorCode: ${errorCode}, due to: ${reason}.`
|
|
|
+ // );
|
|
|
}
|
|
|
}
|
|
|
}
|