From 26f02065dfad9349fd518b2ba3675aecba8ba6e1 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Sat, 10 Dec 2022 16:08:04 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E9=9A=8F=E6=9C=BAPK=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E8=AF=B7=E6=B1=82=E8=BF=9E=E9=BA=A6=E8=B6=85=E6=97=B6?= =?UTF-8?q?=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yunbao/common/manager/IMRTCManager.java | 40 ++++++++++++++++++- .../live/activity/LiveRyAnchorActivity.java | 2 +- .../live/views/LivePushRyViewHolder.java | 1 + 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/com/yunbao/common/manager/IMRTCManager.java b/common/src/main/java/com/yunbao/common/manager/IMRTCManager.java index 3664dc1cd..a095e9b13 100644 --- a/common/src/main/java/com/yunbao/common/manager/IMRTCManager.java +++ b/common/src/main/java/com/yunbao/common/manager/IMRTCManager.java @@ -2,6 +2,9 @@ package com.yunbao.common.manager; import static cn.rongcloud.rtc.base.RTCErrorCode.JOIN_CHAT_ROOM_TIMEOUT; +import android.os.Handler; +import android.os.Looper; + import com.yunbao.common.utils.ToastUtil; import java.util.ArrayList; @@ -10,6 +13,7 @@ import java.util.Map; import java.util.Timer; import java.util.TimerTask; +import cn.rongcloud.rtc.api.RCRTCEngine; import cn.rongcloud.rtc.api.RCRTCRemoteUser; import cn.rongcloud.rtc.api.RCRTCRoom; import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback; @@ -77,6 +81,7 @@ public class IMRTCManager { */ public void requestJoinOtherRoom(String liveUid, boolean inviterAutoMix, String extra, IRCRTCResultCallback callback) { if (requestUid.contains(liveUid)) { + ToastUtil.show("主动拦截"); callback.onFailed(RTCErrorCode.RongRTCCodeJoinRepeatedRoom); return; } @@ -103,6 +108,10 @@ public class IMRTCManager { @Override public void onFailed(RTCErrorCode errorCode) { ToastUtil.show("邀请失败 " + errorCode.getValue()); + if (RandomPkManager.getInstance().isRequestPk()) { + RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_REFUSE); + } + requestUid.remove(liveUid); callback.onFailed(errorCode); } }); @@ -111,6 +120,11 @@ public class IMRTCManager { } } + /** + * 注册监听对方通知类,还没搞清楚具体用法,先搁置 + * + * @param listener + */ public void registerRoomListener(IRCRTCRoomEventsListener listener) { if (rtcRoom != null) { rtcRoom.registerRoomListener(new IRCRTCRoomEventsListener() { @@ -199,18 +213,26 @@ public class IMRTCManager { public void run() { if (!requestUid.contains(liveUid)) { cancel(); + return; } if (waitTime-- == 0) { + new Handler(Looper.getMainLooper()).post(() -> ToastUtil.show("超时清除")); //callback.onFailed(JOIN_CHAT_ROOM_TIMEOUT); cancelRequestJoinOtherRoom(liveUid, "extra", new IRCRTCResultCallback() { @Override public void onSuccess() { requestUid.remove(liveUid); + if (RandomPkManager.getInstance().isRequestPk()) { + RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_REFUSE); + } } @Override public void onFailed(RTCErrorCode errorCode) { - + requestUid.remove(liveUid); + if (RandomPkManager.getInstance().isRequestPk()) { + RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_REFUSE); + } } }); cancel(); @@ -218,4 +240,20 @@ public class IMRTCManager { } }, 1000, 1000); } + + public void leaveOtherRoom(String roomId, + boolean notifyFinished, + IRCRTCResultCallback callBack) { + RCRTCEngine.getInstance().leaveOtherRoom(roomId, notifyFinished, new IRCRTCResultCallback() { + @Override + public void onSuccess() { + callBack.onSuccess(); + } + + @Override + public void onFailed(RTCErrorCode rtcErrorCode) { + callBack.onFailed(rtcErrorCode); + } + }); + } } diff --git a/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java index 6d8b5f321..dafb9aff0 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java @@ -1124,7 +1124,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl } else { ToastUtil.show("主播正在PK,稍後再試"); - if (RandomPkManager.getInstance().isRankModel()) { + if (RandomPkManager.getInstance().isRequestPk()) { RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_REFUSE); } } diff --git a/live/src/main/java/com/yunbao/live/views/LivePushRyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePushRyViewHolder.java index 2d8f67e12..4eea2411f 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePushRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePushRyViewHolder.java @@ -288,6 +288,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX @Override public void onResponseJoinOtherRoom(String inviterRoomId, String inviterUserId, String inviteeRoomId, String inviteeUserId, boolean agree, String extra) { super.onResponseJoinOtherRoom(inviterRoomId, inviterUserId, inviteeRoomId, inviteeUserId, agree, extra); + IMRTCManager.getInstance().callPkSuccess(inviterRoomId); runOnUiThread(new Runnable() { @Override public void run() {