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 c754dffa2..2420c6cf1 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 e069bf58a..b609194ab 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePushRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePushRyViewHolder.java @@ -286,6 +286,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() {