fix:短时间内退出进入房间会重复回调云信?(暂时加个消息id记录过滤)
This commit is contained in:
@@ -20,6 +20,11 @@ import com.yizhuan.xchat_android_core.support.room.RoomHandler
|
||||
**/
|
||||
class RedPackageHandler : RoomHandler() {
|
||||
|
||||
companion object {
|
||||
// 最近收到的红包信令ID
|
||||
private val lastSignalingIdList: MutableList<String> = ArrayList()
|
||||
}
|
||||
|
||||
// 入口图标-数据
|
||||
val iconLiveData: MutableLiveData<RedPackageNotifyInfo?> = MutableLiveData()
|
||||
|
||||
@@ -69,10 +74,28 @@ class RedPackageHandler : RoomHandler() {
|
||||
private fun registerSignaling() {
|
||||
// TODO 临时方案:不应在这里直接监听IM,后续会统一分发出口
|
||||
// 信令来源:新/旧版的厅内红包,非全服红包
|
||||
IMNetEaseManager.get().chatRoomEventObservable
|
||||
val d = IMNetEaseManager.get().chatRoomEventObservable
|
||||
.compose<RoomEvent>(bindToLifecycle<RoomEvent>())
|
||||
.filter {
|
||||
it?.event == RoomEvent.RECEIVE_RED_PACKAGE && it?.chatRoomMessage?.attachment is RedPackageAttachment
|
||||
it.event == RoomEvent.RECEIVE_RED_PACKAGE && it.chatRoomMessage?.attachment is RedPackageAttachment
|
||||
}
|
||||
.filter {
|
||||
val uuid = it.chatRoomMessage.uuid
|
||||
if (uuid != null) {
|
||||
// TODO:判断是否收到过该消息(发现如果短时间内退出再进房,云信会重复回调,暂时没时间详细排查是我们代码导致还是云信bug,先简单加个记录过滤)
|
||||
val result = lastSignalingIdList.contains(uuid)
|
||||
lastSignalingIdList.add(uuid)
|
||||
if (lastSignalingIdList.size > 20) {
|
||||
repeat(10) {
|
||||
if (lastSignalingIdList.isNotEmpty()) {
|
||||
lastSignalingIdList.removeAt(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
!result
|
||||
} else {
|
||||
true
|
||||
}
|
||||
}.map {
|
||||
(it.chatRoomMessage.attachment as RedPackageAttachment).getRedPackageNotifyInfo()
|
||||
}
|
||||
@@ -124,6 +147,7 @@ class RedPackageHandler : RoomHandler() {
|
||||
return
|
||||
}
|
||||
if (!isSignaling) {
|
||||
// 只有信令才弹
|
||||
return
|
||||
}
|
||||
if (data.kind == 0 || (data.kind == 1 && data.validityType == 0)) {
|
||||
|
Reference in New Issue
Block a user