update 随机PK 新增请求连麦超时管理
This commit is contained in:
parent
e0287899f8
commit
26f02065df
@ -2,6 +2,9 @@ package com.yunbao.common.manager;
|
|||||||
|
|
||||||
import static cn.rongcloud.rtc.base.RTCErrorCode.JOIN_CHAT_ROOM_TIMEOUT;
|
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 com.yunbao.common.utils.ToastUtil;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -10,6 +13,7 @@ import java.util.Map;
|
|||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
|
||||||
|
import cn.rongcloud.rtc.api.RCRTCEngine;
|
||||||
import cn.rongcloud.rtc.api.RCRTCRemoteUser;
|
import cn.rongcloud.rtc.api.RCRTCRemoteUser;
|
||||||
import cn.rongcloud.rtc.api.RCRTCRoom;
|
import cn.rongcloud.rtc.api.RCRTCRoom;
|
||||||
import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback;
|
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) {
|
public void requestJoinOtherRoom(String liveUid, boolean inviterAutoMix, String extra, IRCRTCResultCallback callback) {
|
||||||
if (requestUid.contains(liveUid)) {
|
if (requestUid.contains(liveUid)) {
|
||||||
|
ToastUtil.show("主动拦截");
|
||||||
callback.onFailed(RTCErrorCode.RongRTCCodeJoinRepeatedRoom);
|
callback.onFailed(RTCErrorCode.RongRTCCodeJoinRepeatedRoom);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -103,6 +108,10 @@ public class IMRTCManager {
|
|||||||
@Override
|
@Override
|
||||||
public void onFailed(RTCErrorCode errorCode) {
|
public void onFailed(RTCErrorCode errorCode) {
|
||||||
ToastUtil.show("邀请失败 " + errorCode.getValue());
|
ToastUtil.show("邀请失败 " + errorCode.getValue());
|
||||||
|
if (RandomPkManager.getInstance().isRequestPk()) {
|
||||||
|
RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_REFUSE);
|
||||||
|
}
|
||||||
|
requestUid.remove(liveUid);
|
||||||
callback.onFailed(errorCode);
|
callback.onFailed(errorCode);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -111,6 +120,11 @@ public class IMRTCManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注册监听对方通知类,还没搞清楚具体用法,先搁置
|
||||||
|
*
|
||||||
|
* @param listener
|
||||||
|
*/
|
||||||
public void registerRoomListener(IRCRTCRoomEventsListener listener) {
|
public void registerRoomListener(IRCRTCRoomEventsListener listener) {
|
||||||
if (rtcRoom != null) {
|
if (rtcRoom != null) {
|
||||||
rtcRoom.registerRoomListener(new IRCRTCRoomEventsListener() {
|
rtcRoom.registerRoomListener(new IRCRTCRoomEventsListener() {
|
||||||
@ -199,18 +213,26 @@ public class IMRTCManager {
|
|||||||
public void run() {
|
public void run() {
|
||||||
if (!requestUid.contains(liveUid)) {
|
if (!requestUid.contains(liveUid)) {
|
||||||
cancel();
|
cancel();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (waitTime-- == 0) {
|
if (waitTime-- == 0) {
|
||||||
|
new Handler(Looper.getMainLooper()).post(() -> ToastUtil.show("超时清除"));
|
||||||
//callback.onFailed(JOIN_CHAT_ROOM_TIMEOUT);
|
//callback.onFailed(JOIN_CHAT_ROOM_TIMEOUT);
|
||||||
cancelRequestJoinOtherRoom(liveUid, "extra", new IRCRTCResultCallback() {
|
cancelRequestJoinOtherRoom(liveUid, "extra", new IRCRTCResultCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess() {
|
public void onSuccess() {
|
||||||
requestUid.remove(liveUid);
|
requestUid.remove(liveUid);
|
||||||
|
if (RandomPkManager.getInstance().isRequestPk()) {
|
||||||
|
RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_REFUSE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailed(RTCErrorCode errorCode) {
|
public void onFailed(RTCErrorCode errorCode) {
|
||||||
|
requestUid.remove(liveUid);
|
||||||
|
if (RandomPkManager.getInstance().isRequestPk()) {
|
||||||
|
RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_REFUSE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
cancel();
|
cancel();
|
||||||
@ -218,4 +240,20 @@ public class IMRTCManager {
|
|||||||
}
|
}
|
||||||
}, 1000, 1000);
|
}, 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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1124,7 +1124,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
ToastUtil.show("主播正在PK,稍後再試");
|
ToastUtil.show("主播正在PK,稍後再試");
|
||||||
if (RandomPkManager.getInstance().isRankModel()) {
|
if (RandomPkManager.getInstance().isRequestPk()) {
|
||||||
RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_REFUSE);
|
RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_REFUSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -288,6 +288,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
|
|||||||
@Override
|
@Override
|
||||||
public void onResponseJoinOtherRoom(String inviterRoomId, String inviterUserId, String inviteeRoomId, String inviteeUserId, boolean agree, String extra) {
|
public void onResponseJoinOtherRoom(String inviterRoomId, String inviterUserId, String inviteeRoomId, String inviteeUserId, boolean agree, String extra) {
|
||||||
super.onResponseJoinOtherRoom(inviterRoomId, inviterUserId, inviteeRoomId, inviteeUserId, agree, extra);
|
super.onResponseJoinOtherRoom(inviterRoomId, inviterUserId, inviteeRoomId, inviteeUserId, agree, extra);
|
||||||
|
IMRTCManager.getInstance().callPkSuccess(inviterRoomId);
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
Loading…
Reference in New Issue
Block a user