feat:新增聚会房、狂欢房;
This commit is contained in:
@@ -430,13 +430,13 @@ public final class AvRoomDataManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void updateQueueChatRoomMemberExtension(ChatRoomMember chatRoomMember) {
|
||||
int size = mMicQueueMemberMap.size();
|
||||
public void updateQueueChatRoomMemberExtension(SparseArray<RoomQueueInfo> queue, ChatRoomMember chatRoomMember) {
|
||||
int size = queue.size();
|
||||
if (chatRoomMember == null || chatRoomMember.getExtension() == null ||
|
||||
TextUtils.isEmpty(chatRoomMember.getAccount())) return;
|
||||
for (int i = 0; i < size; i++) {
|
||||
int key = mMicQueueMemberMap.keyAt(i);
|
||||
RoomQueueInfo roomQueueInfo = mMicQueueMemberMap.get(key);
|
||||
int key = queue.keyAt(i);
|
||||
RoomQueueInfo roomQueueInfo = queue.get(key);
|
||||
if (roomQueueInfo == null || roomQueueInfo.mChatRoomMember == null) continue;
|
||||
if (!chatRoomMember.getAccount().equals(roomQueueInfo.mChatRoomMember.getAccount()))
|
||||
continue;
|
||||
@@ -594,6 +594,13 @@ public final class AvRoomDataManager {
|
||||
return mCurrentRoomInfo != null && mCurrentRoomInfo.getType() == RoomInfo.ROOM_TYPE_SINGLE;
|
||||
}
|
||||
|
||||
public int getRoomType() {
|
||||
if (mCurrentRoomInfo == null) {
|
||||
return -1;
|
||||
}
|
||||
return mCurrentRoomInfo.getType();
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是房间管理员
|
||||
*
|
||||
@@ -844,6 +851,16 @@ public final class AvRoomDataManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void replaceMicQueue(SparseArray<RoomQueueInfo> queue) {
|
||||
if (queue == null) {
|
||||
return;
|
||||
}
|
||||
mMicQueueMemberMap.clear();
|
||||
for (int i = 0; i < queue.size(); i++) {
|
||||
mMicQueueMemberMap.put(queue.keyAt(i), queue.valueAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是房主或管理员
|
||||
*
|
||||
|
@@ -126,7 +126,6 @@ import com.chwl.core.miniworld.bean.MiniWorldDetailInfo;
|
||||
import com.chwl.core.miniworld.bean.MiniWorldDetailInfoWithCurrentMember;
|
||||
import com.chwl.core.miniworld.event.MiniWorldJoinVerifiedEvent;
|
||||
import com.chwl.core.monsterhunting.bean.MonsterInfo;
|
||||
import com.chwl.core.monsterhunting.bean.MonsterProtocol;
|
||||
import com.chwl.core.msg.sys.bean.ErbanSysMsgInfo;
|
||||
import com.chwl.core.msg.sys.ErbanSysMsgParamKey;
|
||||
import com.chwl.core.msg.sysv2.bean.ErbanSysMsgV2Info;
|
||||
@@ -1840,15 +1839,39 @@ public final class IMNetEaseManager {
|
||||
private void roomInfoUpdate(Map<String, Object> extension) {
|
||||
String roomInfoStr = (String) extension.get("roomInfo");
|
||||
if (!TextUtils.isEmpty(roomInfoStr)) {
|
||||
LogUtils.d(roomInfoStr);
|
||||
com.example.lib_utils.log.LogUtil.d(TAG, "roomInfoUpdate roomInfoStr:" + roomInfoStr, false);
|
||||
RoomInfo roomInfo = gson.fromJson(roomInfoStr, RoomInfo.class);
|
||||
if (roomInfo != null) {
|
||||
boolean isTypeChanged = false;
|
||||
if (AvRoomDataManager.get().mCurrentRoomInfo != null && AvRoomDataManager.get().mCurrentRoomInfo.getType() != roomInfo.getType()) {
|
||||
isTypeChanged = true;
|
||||
}
|
||||
AvRoomDataManager.get().mCurrentRoomInfo = roomInfo;
|
||||
noticeRoomInfoUpdate(roomInfo);
|
||||
com.example.lib_utils.log.LogUtil.d(TAG, "roomInfoUpdate isTypeChanged:" + isTypeChanged, false);
|
||||
if (isTypeChanged) {
|
||||
onRoomTypeChanged(roomInfo);
|
||||
}else{
|
||||
AvRoomDataManager.get().mCurrentRoomInfo = roomInfo;
|
||||
noticeRoomInfoUpdate(roomInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private void onRoomTypeChanged(RoomInfo roomInfo) {
|
||||
RoomMicQueueModel.INSTANCE.queueMicQueue(roomInfo.getRoomId()).subscribe(new Consumer<SparseArray<RoomQueueInfo>>() {
|
||||
@Override
|
||||
public void accept(SparseArray<RoomQueueInfo> roomQueue) throws Exception {
|
||||
com.example.lib_utils.log.LogUtil.d(TAG, "onRoomTypeChanged accept", false);
|
||||
AvRoomDataManager.get().replaceMicQueue(roomQueue);
|
||||
GiftValueMrg.get().updateRoomGiftValue(false);
|
||||
noticeRoomInfoUpdate(roomInfo);
|
||||
tryAutoUpMic();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void chatRoomQueueChangeNotice(ChatRoomMessage msg) {
|
||||
ChatRoomQueueChangeAttachment roomQueueChangeAttachment = (ChatRoomQueueChangeAttachment) msg.getAttachment();
|
||||
//麥上成員信息(uid...) key:坑位 ,content:{"nick":"行走的老者","uid":90972,"gender":1,"avatar":"https://image.zhongjialx.com/Fmtbprx5cGc3KABKjDxs_udJZb3O?imageslim"}
|
||||
@@ -1903,7 +1926,13 @@ public final class IMNetEaseManager {
|
||||
if (curRoomInfo == null) return;
|
||||
noticeEnterMessages();
|
||||
//個播模式房主進房自動上麥
|
||||
if (AvRoomDataManager.get().isSingleRoom() && AvRoomDataManager.get().isRoomOwner()) {
|
||||
tryAutoUpMic();
|
||||
}
|
||||
|
||||
private void tryAutoUpMic() {
|
||||
RoomInfo curRoomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
|
||||
if (curRoomInfo == null) return;
|
||||
if (AvRoomDataManager.get().isSingleRoom() && AvRoomDataManager.get().isRoomOwner() && !AvRoomDataManager.get().isOwnerOnMic()) {
|
||||
AvRoomModel.get().upMicroPhone(
|
||||
-1,
|
||||
String.valueOf(AuthModel.get().getCurrentUid()),
|
||||
@@ -1922,7 +1951,6 @@ public final class IMNetEaseManager {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public ChatRoomMessage getFirstMessageContent() {
|
||||
|
130
core/src/main/java/com/chwl/core/manager/RoomMicQueueModel.kt
Normal file
130
core/src/main/java/com/chwl/core/manager/RoomMicQueueModel.kt
Normal file
@@ -0,0 +1,130 @@
|
||||
package com.chwl.core.manager
|
||||
|
||||
import android.util.Log
|
||||
import android.util.SparseArray
|
||||
import com.chwl.core.Constants
|
||||
import com.chwl.core.bean.RoomMicInfo
|
||||
import com.chwl.core.bean.RoomQueueInfo
|
||||
import com.chwl.core.room.model.AvRoomModel
|
||||
import com.chwl.core.room.queue.bean.MicMemberInfo
|
||||
import com.chwl.library.utils.ListUtils
|
||||
import com.chwl.library.utils.json.JsonUtils
|
||||
import com.example.lib_utils.log.ILog
|
||||
import com.google.gson.JsonParser
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomInfo
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMember
|
||||
import com.netease.nimlib.sdk.util.Entry
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.Single
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
|
||||
object RoomMicQueueModel : ILog {
|
||||
|
||||
fun queueMicQueue(roomId: Long): Observable<SparseArray<RoomQueueInfo>> {
|
||||
return AvRoomModel.get().queryRoomInfo(roomId).map {
|
||||
parseMicQueue(it)
|
||||
}.flatMap {
|
||||
queueMicQueue(roomId, it)
|
||||
}
|
||||
}
|
||||
|
||||
fun queueMicQueue(
|
||||
roomId: Long,
|
||||
queue: SparseArray<RoomQueueInfo>
|
||||
): Observable<SparseArray<RoomQueueInfo>> {
|
||||
return AvRoomModel.get().queryRoomMicInfo(roomId.toString()).map {
|
||||
dealMicMemberFromIMNet(queue, it)
|
||||
}.flatMap {
|
||||
dealMicChatRoomMemberFromIMNet(queue, it)
|
||||
}
|
||||
}
|
||||
|
||||
private fun parseMicQueue(
|
||||
chatRoomInfo: ChatRoomInfo
|
||||
): SparseArray<RoomQueueInfo> {
|
||||
val extension: Map<String, Any> = chatRoomInfo.extension
|
||||
val micQueueStr =
|
||||
extension[Constants.KEY_CHAT_ROOM_INFO_MIC] as? String
|
||||
return parseMicQueue(micQueueStr)
|
||||
}
|
||||
|
||||
private fun parseMicQueue(
|
||||
micQueueStr: String?
|
||||
): SparseArray<RoomQueueInfo> {
|
||||
val micQueue = SparseArray<RoomQueueInfo>()
|
||||
if (micQueueStr.isNullOrEmpty()) {
|
||||
return micQueue
|
||||
}
|
||||
val micQueueMap = JsonUtils.getGson().fromJson<Map<String, String?>>(
|
||||
micQueueStr, object : TypeToken<Map<String, String?>>() {}.type
|
||||
)
|
||||
logD("parseMicQueue micQueueStr:$micQueueStr")
|
||||
micQueueMap.forEach {
|
||||
val micPosition = it.key.toIntOrNull()
|
||||
val micInfo =
|
||||
JsonUtils.getGson().fromJson<RoomMicInfo>(it.value, RoomMicInfo::class.java)
|
||||
if (micPosition != null && micInfo != null) {
|
||||
micQueue.put(
|
||||
micPosition,
|
||||
RoomQueueInfo(
|
||||
micInfo,
|
||||
null
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
return micQueue
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理网易云信坑位信息
|
||||
*/
|
||||
private fun dealMicMemberFromIMNet(
|
||||
micQueue: SparseArray<RoomQueueInfo>,
|
||||
entries: List<Entry<String, String>>
|
||||
): List<String> {
|
||||
logD("dealMicMemberFromIMNet entries:${entries.size}")
|
||||
val accounts: MutableList<String> = ArrayList()
|
||||
if (!ListUtils.isListEmpty(entries)) {
|
||||
val jsonParser = JsonParser()
|
||||
var chatRoomMember: MicMemberInfo
|
||||
for (entry in entries) {
|
||||
val roomQueueInfo = micQueue[entry.key.toInt()]
|
||||
if (roomQueueInfo != null) {
|
||||
val valueJsonObj = jsonParser.parse(entry.value).asJsonObject
|
||||
if (valueJsonObj != null) {
|
||||
chatRoomMember =
|
||||
JsonUtils.getGson()
|
||||
.fromJson<MicMemberInfo>(valueJsonObj, MicMemberInfo::class.java)
|
||||
accounts.add(chatRoomMember.account)
|
||||
roomQueueInfo.mChatRoomMember = chatRoomMember
|
||||
}
|
||||
micQueue.put(
|
||||
Integer.valueOf(entry.key),
|
||||
roomQueueInfo
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
return accounts
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理网易云信队列上人员的信息
|
||||
*/
|
||||
private fun dealMicChatRoomMemberFromIMNet(
|
||||
micQueue: SparseArray<RoomQueueInfo>,
|
||||
accounts: List<String>
|
||||
): Observable<SparseArray<RoomQueueInfo>> {
|
||||
return if (ListUtils.isListEmpty(accounts)) Observable.just(micQueue) else IMNetEaseManager.get()
|
||||
.fetchRoomMembersByIds(accounts).observeOn(AndroidSchedulers.mainThread())
|
||||
.flatMap { chatRoomMembers: List<ChatRoomMember?> ->
|
||||
for (chatRoomMember in chatRoomMembers) {
|
||||
AvRoomDataManager.get()
|
||||
.updateQueueChatRoomMemberExtension(micQueue, chatRoomMember)
|
||||
}
|
||||
Single.just(micQueue)
|
||||
}.toObservable()
|
||||
}
|
||||
}
|
@@ -436,7 +436,7 @@ public class RoomBaseModel extends BaseModel implements IRoomBaseModel {
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.flatMap(chatRoomMembers -> {
|
||||
for (ChatRoomMember chatRoomMember : chatRoomMembers) {
|
||||
AvRoomDataManager.get().updateQueueChatRoomMemberExtension(chatRoomMember);
|
||||
AvRoomDataManager.get().updateQueueChatRoomMemberExtension(AvRoomDataManager.get().mMicQueueMemberMap, chatRoomMember);
|
||||
}
|
||||
//accounts不为空则表示出现了本地队列信息和云信队列信息不一致的情况,更新队列信息后更新下相应的坑位信息
|
||||
|
||||
@@ -710,6 +710,16 @@ public class RoomBaseModel extends BaseModel implements IRoomBaseModel {
|
||||
*/
|
||||
@Override
|
||||
public Observable<ChatRoomInfo> startGetOnlineMemberNumberJob(final long roomId) {
|
||||
return queryRoomInfo(roomId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取聊天室信息
|
||||
*
|
||||
* @param roomId 聊天室id
|
||||
* @return ChatRoomInfo 房间信息
|
||||
*/
|
||||
public Observable<ChatRoomInfo> queryRoomInfo(final long roomId) {
|
||||
return Observable.create(new ObservableOnSubscribe<ChatRoomInfo>() {
|
||||
@Override
|
||||
public void subscribe(ObservableEmitter<ChatRoomInfo> e) throws Exception {
|
||||
|
@@ -69,6 +69,14 @@ public class MicMemberInfo {
|
||||
|
||||
}
|
||||
|
||||
public String getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
public String getNick() {
|
||||
return nick;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
Reference in New Issue
Block a user