Merge branch 'dev_random_pk'

This commit is contained in:
zlzw 2022-12-10 17:30:48 +08:00
commit b188613035
3 changed files with 41 additions and 2 deletions

View File

@ -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);
}
});
}
}

View File

@ -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);
}
}

View File

@ -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() {