被踢后5分钟内不能进入此房间
This commit is contained in:
@@ -282,7 +282,11 @@ public class XChatConstants {
|
||||
* 聊天室文本消息易盾反垃圾业务id
|
||||
*/
|
||||
public static final String CHAT_ROOM_ANTI_SPAM_CONFIG_ID = BuildConfig.DEBUG ? "be58dfa4a664540006f0ed1f752d604a" : "244721766ba607056a32c8824a85c253";
|
||||
|
||||
public static final int KICK_OUT_ROOM_LIMIT_ENTER_TIME = 5 * 60 * 1000;
|
||||
|
||||
public static int SELECT_ANIM_DURATION = 2500;
|
||||
|
||||
public static long ZEGO_APP_ID = 1067458582L;
|
||||
public static byte[] ZEGO_APP_SIGN = new byte[]{
|
||||
(byte) 0x2b, (byte) 0x86, (byte) 0x24, (byte) 0xef, (byte) 0xd9, (byte) 0x96, (byte) 0xf1, (byte) 0x1c, (byte) 0x6b,
|
||||
|
@@ -7,6 +7,7 @@ import androidx.annotation.Nullable;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.netease.nimlib.sdk.StatusBarNotificationConfig;
|
||||
import com.yizhuan.xchat_android_constants.XChatConstants;
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel;
|
||||
import com.yizhuan.xchat_android_core.auth.entity.AccountInfo;
|
||||
import com.yizhuan.xchat_android_core.auth.entity.TicketInfo;
|
||||
@@ -55,6 +56,7 @@ public class DemoCache {
|
||||
private static final String KEY_ANCHOR_CARD_VIEW_TIME = "key_anchor_card_view_time";
|
||||
private static final String KEY_LAUNCH_COUNT = "key_launch_count";
|
||||
private static final String KEY_RADISH_TIPS = "key_radish_tips";
|
||||
private static final String KEY_KICK_OUT_ROOM = "kick_out_room";
|
||||
|
||||
private static StatusBarNotificationConfig notificationConfig;
|
||||
|
||||
@@ -303,5 +305,26 @@ public class DemoCache {
|
||||
return SettingsPref.instance().getBoolean(KEY_RADISH_TIPS, true);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Map<String, Long> readKickOutRoom() {
|
||||
String string = SettingsPref.instance().getString(KEY_KICK_OUT_ROOM, null);
|
||||
if (TextUtils.isEmpty(string)) return null;
|
||||
return new Gson().fromJson(string,
|
||||
new TypeToken<Map<String, Long>>() {
|
||||
}.getType());
|
||||
}
|
||||
|
||||
public static void saveKickOutRoom(String roomUid) {
|
||||
Map<String, Long> map = readKickOutRoom();
|
||||
if (map == null) map = new HashMap<>();
|
||||
for (Iterator<Map.Entry<String, Long>> it = map.entrySet().iterator(); it.hasNext(); ) {
|
||||
if (CurrentTimeUtils.getCurrentTime() - it.next().getValue() > XChatConstants.KICK_OUT_ROOM_LIMIT_ENTER_TIME) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
map.put(roomUid, CurrentTimeUtils.getCurrentTime());
|
||||
SettingsPref.instance().putString(KEY_KICK_OUT_ROOM, new Gson().toJson(map));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -22,6 +22,8 @@ import com.netease.nimlib.sdk.chatroom.model.EnterChatRoomResultData;
|
||||
import com.netease.nimlib.sdk.msg.attachment.NotificationAttachment;
|
||||
import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum;
|
||||
import com.netease.nimlib.sdk.msg.constant.NotificationType;
|
||||
import com.yizhuan.xchat_android_constants.XChatConstants;
|
||||
import com.yizhuan.xchat_android_core.DemoCache;
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel;
|
||||
import com.yizhuan.xchat_android_core.bean.RoomQueueInfo;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RoomPkBean;
|
||||
@@ -36,6 +38,7 @@ import com.yizhuan.xchat_android_core.room.bean.RoomModeType;
|
||||
import com.yizhuan.xchat_android_core.super_admin.SuperAdminDataMrg;
|
||||
import com.yizhuan.xchat_android_core.super_admin.util.SuperAdminUtil;
|
||||
import com.yizhuan.xchat_android_core.user.UserModel;
|
||||
import com.yizhuan.xchat_android_core.utils.CurrentTimeUtils;
|
||||
import com.yizhuan.xchat_android_core.utils.LogUtils;
|
||||
import com.yizhuan.xchat_android_core.utils.StringUtils;
|
||||
import com.yizhuan.xchat_android_library.rxbus.RxBus;
|
||||
@@ -93,6 +96,11 @@ public final class AvRoomDataManager {
|
||||
public final List<ChatRoomMember> roomSuperAdminList = new ArrayList<>();
|
||||
@NonNull
|
||||
public final MutableLiveData<RoomPkBean> roomPkLiveData = new MutableLiveData<>();
|
||||
/**
|
||||
* 是否需要关麦,用户自己的行为,不受房主管理员的管理,与闭麦状态相同,当闭麦这个值就是ture;
|
||||
* 2022/9/1更改:无论什么情况上麦,默认都是关麦的!
|
||||
*/
|
||||
public final boolean mIsNeedOpenMic = true;
|
||||
private final PublishProcessor<List<ChatRoomMessage>> chatRoomMsgProcessor = PublishProcessor.create();
|
||||
@Nullable
|
||||
public RoomInfo mCurrentRoomInfo;
|
||||
@@ -138,11 +146,6 @@ public final class AvRoomDataManager {
|
||||
* 坑位上用户的头饰
|
||||
*/
|
||||
public HashMap<String, List<Drawable>> mHeadWearMap;
|
||||
/**
|
||||
* 是否需要关麦,用户自己的行为,不受房主管理员的管理,与闭麦状态相同,当闭麦这个值就是ture;
|
||||
* 2022/9/1更改:无论什么情况上麦,默认都是关麦的!
|
||||
*/
|
||||
public final boolean mIsNeedOpenMic = true;
|
||||
/**
|
||||
* 是否需要打开礼物特效
|
||||
*/
|
||||
@@ -210,6 +213,10 @@ public final class AvRoomDataManager {
|
||||
* 公屏数据
|
||||
*/
|
||||
private List<ChatRoomMessage> chatRoomMessages = new LinkedList<>();
|
||||
/**
|
||||
* 记录该用户被踢房间的uid
|
||||
*/
|
||||
private Map<String, Long> kickOutRoomUids;
|
||||
|
||||
private AvRoomDataManager() {
|
||||
mRoomManagerList = new ArrayList<>();
|
||||
@@ -222,6 +229,8 @@ public final class AvRoomDataManager {
|
||||
dragons = new ArrayList<>();
|
||||
mHeadWearMap = new HashMap<>();
|
||||
observerChatRoomMessage();
|
||||
kickOutRoomUids = DemoCache.readKickOutRoom();
|
||||
if (kickOutRoomUids == null) kickOutRoomUids = new HashMap<>();
|
||||
}
|
||||
|
||||
public static AvRoomDataManager get() {
|
||||
@@ -244,23 +253,24 @@ public final class AvRoomDataManager {
|
||||
|
||||
/**
|
||||
* 云信的RoomInfo和我们服务端的RoomInfo是不同步的,需要单独保存一下有用到的字段
|
||||
*
|
||||
* @param roomInfo
|
||||
*/
|
||||
|
||||
public void updateServiceRoomInfo(RoomInfo roomInfo){
|
||||
public void updateServiceRoomInfo(RoomInfo roomInfo) {
|
||||
//我们自己服务端信息
|
||||
mCurrentRoomInfo = roomInfo;
|
||||
mBoxSwitchVo = roomInfo.boxSwitchVo;
|
||||
phrases = roomInfo.getSpeakTemplate();
|
||||
nick = roomInfo.getNick();
|
||||
gender = roomInfo.getGender();
|
||||
avatar = roomInfo.getAvatar();
|
||||
isRoomFans = roomInfo.isRoomFans();
|
||||
trtcSig = roomInfo.getTrtcSig();
|
||||
clearScreenTime = roomInfo.getClearScreenTime();
|
||||
showPkBeginTime = roomInfo.isShowPkBeginTime();
|
||||
pkBeginTime = roomInfo.getPkBeginTime();
|
||||
redEnvelopeOpen = roomInfo.isRedEnvelopeOpen();
|
||||
mCurrentRoomInfo = roomInfo;
|
||||
mBoxSwitchVo = roomInfo.boxSwitchVo;
|
||||
phrases = roomInfo.getSpeakTemplate();
|
||||
nick = roomInfo.getNick();
|
||||
gender = roomInfo.getGender();
|
||||
avatar = roomInfo.getAvatar();
|
||||
isRoomFans = roomInfo.isRoomFans();
|
||||
trtcSig = roomInfo.getTrtcSig();
|
||||
clearScreenTime = roomInfo.getClearScreenTime();
|
||||
showPkBeginTime = roomInfo.isShowPkBeginTime();
|
||||
pkBeginTime = roomInfo.getPkBeginTime();
|
||||
redEnvelopeOpen = roomInfo.isRedEnvelopeOpen();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1292,6 +1302,18 @@ public final class AvRoomDataManager {
|
||||
return isDatingMode() && roomQueueInfo.mChatRoomMember.isHasSelectUser();
|
||||
}
|
||||
|
||||
public boolean isLimitEnterRoom(String roomUid) {
|
||||
Long limitTime = kickOutRoomUids.get(roomUid);
|
||||
return limitTime != null && CurrentTimeUtils.getCurrentTime() - limitTime < XChatConstants.KICK_OUT_ROOM_LIMIT_ENTER_TIME;
|
||||
}
|
||||
|
||||
public void addCurrentRoomLimitEnter() {
|
||||
if (mCurrentRoomInfo == null) return;
|
||||
String roomUid = String.valueOf(getRoomUid());
|
||||
kickOutRoomUids.put(roomUid, CurrentTimeUtils.getCurrentTime());
|
||||
DemoCache.saveKickOutRoom(roomUid);
|
||||
}
|
||||
|
||||
private static final class Helper {
|
||||
private static final AvRoomDataManager INSTANCE = new AvRoomDataManager();
|
||||
}
|
||||
|
Reference in New Issue
Block a user