1:修改在线用户展示

2:修改最小化进入房间更新数据
This commit is contained in:
2025-12-09 18:14:52 +08:00
parent 8b9fd2ba08
commit 0d188736b2
5 changed files with 140 additions and 162 deletions

View File

@@ -94,20 +94,23 @@ public class RoomManager {
if (CommonAppContext.getInstance().playId == null) {
fetchAndJoinRoom(context, roomId, password, taskId);
} else {
if (!CommonAppContext.getInstance().playId.equals(roomId)) {
if (!CommonAppContext.getInstance().playId.equals(roomId)) {//这是判断点击的和存储的roomId是否相同不相同就退出记录的id然后加入新的roomId
MessageListenerSingleton.getInstance().joinGroup(roomId);
exitRoom(CommonAppContext.getInstance().playId);
CommonAppContext.getInstance().isShow = false;
CommonAppContext.getInstance().isPlaying = false;
CommonAppContext.getInstance().isRoomJoininj = false;
EventBus.getDefault().post(new RoomOutEvent());
//2025年12月9日17:39:21 修改将获取在线用户判断是否在房间进行关闭原因是服务端不在踢人了所以点击最小化的时候就直接走room_info接口
upInfo(context, roomId, password, false, roomInfo, true, taskId);
return;
// fetchAndJoinRoom(context, roomId, password, taskId);
// return;
} else if (CommonAppContext.getInstance().lable_id.equals("6")) {
} else if (CommonAppContext.getInstance().lable_id.equals("6")) {//这是判断是否是小黑屋是小黑屋进行更新走room_info接口
upInfo(context, roomId, password, true, roomInfo, true, taskId);
return;
}
//这里是点击的roomId和存错的id是同一个的时候就走的是更新roomInfo接口
isUserOnline(context, roomId, password, roomInfo, taskId);
}
}
@@ -293,47 +296,48 @@ public class RoomManager {
// 可以通过检查Agora是否还在房间中或者通过服务端接口查询用户状态等方式实现
// 目前返回false需要根据实际需求实现具体逻辑
final boolean[] isOnline = {false};
RetrofitClient.getInstance().getRoomOnline(roomId, "1", "50", new BaseObserver<RoomOnline>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(RoomOnline roomOnline) {
try {
if (roomOnline != null) {
if (roomOnline.getOn_pit() != null) {
for (RoomOnlineBean roomOnlineBean : roomOnline.getOn_pit()) {
if (roomOnlineBean.getUser_id() == SpUtil.getUserId()) {
isOnline[0] = true;
break;
}
}
}
if (roomOnline.getOff_pit() != null) {
for (RoomOnlineBean roomOnlineBean : roomOnline.getOff_pit()) {
if (roomOnlineBean.getUser_id() == SpUtil.getUserId()) {
isOnline[0] = true;
break;
}
}
}
upInfo(context, roomId, password, isOnline[0], roomInfo, true, taskId);
} else {
isOnline[0] = false;
}
} catch (Exception e) {
// 捕获所有可能的异常,避免崩溃
e.printStackTrace();
isOnline[0] = false;
// 即使出现异常也继续执行
upInfo(context, roomId, password, isOnline[0], roomInfo, true, taskId);
}
}
});
// final boolean[] isOnline = {false};
// RetrofitClient.getInstance().getRoomOnline(roomId, "1", "50", new BaseObserver<RoomOnline>() {
// @Override
// public void onSubscribe(Disposable d) {
//
// }
//
// @Override
// public void onNext(RoomOnline roomOnline) {
// try {
// if (roomOnline != null) {
// if (roomOnline.getOn_pit() != null) {
// for (RoomOnlineBean roomOnlineBean : roomOnline.getOn_pit()) {
// if (roomOnlineBean.getUser_id() == SpUtil.getUserId()) {
// isOnline[0] = true;
// break;
// }
// }
// }
// if (roomOnline.getOff_pit() != null) {
// for (RoomOnlineBean roomOnlineBean : roomOnline.getOff_pit()) {
// if (roomOnlineBean.getUser_id() == SpUtil.getUserId()) {
// isOnline[0] = true;
// break;
// }
// }
// }
// upInfo(context, roomId, password, isOnline[0], roomInfo, true, taskId);
//
// } else {
// isOnline[0] = false;
// }
// } catch (Exception e) {
// // 捕获所有可能的异常,避免崩溃
// e.printStackTrace();
// isOnline[0] = false;
// // 即使出现异常也继续执行
// upInfo(context, roomId, password, isOnline[0], roomInfo, true, taskId);
// }
// }
// });
upInfo(context, roomId, password, true, roomInfo, true, taskId);
return false;
}