[Fix] 增加了被踢掉出房间后重新进入防止web给踢掉之后无法使用的问题

This commit is contained in:
donghongyu
2021-12-28 11:44:57 +08:00
parent e5293b24b7
commit 3ed9a071bc
4 changed files with 77 additions and 28 deletions

26
.idea/deploymentTargetDropDown.xml generated Normal file
View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetDropDown">
<multipleDevicesSelectedInDropDown value="true" />
<runningDeviceTargetsSelectedWithDialog>
<Target>
<type value="RUNNING_DEVICE_TARGET" />
<deviceKey>
<Key>
<type value="SERIAL_NUMBER" />
<value value="JAM6R20C10001418" />
</Key>
</deviceKey>
</Target>
<Target>
<type value="RUNNING_DEVICE_TARGET" />
<deviceKey>
<Key>
<type value="SERIAL_NUMBER" />
<value value="HA1DGRAS" />
</Key>
</deviceKey>
</Target>
</runningDeviceTargetsSelectedWithDialog>
</component>
</project>

4
.idea/misc.xml generated
View File

@@ -8,6 +8,10 @@
<asm skipDebug="false" skipFrames="false" skipCode="false" expandFrames="false" />
<groovy codeStyle="LEGACY" />
</component>
<component name="ASMSmaliIdeaPluginConfiguration">
<asm skipDebug="true" skipFrames="true" skipCode="false" expandFrames="false" />
<groovy codeStyle="LEGACY" />
</component>
<component name="DesignSurface">
<option name="filePathToZoomLevelMap">
<map>

View File

@@ -5,6 +5,7 @@ import static com.mogo.cloud.httpdns.MogoHttpDnsConfig.HTTP_DNS_ENV_DEV;
import static com.mogo.cloud.httpdns.MogoHttpDnsConfig.HTTP_DNS_ENV_QA;
import static com.mogo.cloud.httpdns.MogoHttpDnsConfig.HTTP_DNS_ENV_RELEASE;
import static im.zego.zegoexpress.constants.ZegoRemoteDeviceState.OPEN;
import static im.zego.zegoexpress.constants.ZegoRoomState.DISCONNECTED;
import android.app.Application;
import android.text.TextUtils;
@@ -21,6 +22,7 @@ import com.mogo.cloud.live.listener.IMediaPlayerStateListener;
import com.mogo.cloud.live.model.LiveStatusModel;
import com.mogo.cloud.live.server.PushService;
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
import com.mogo.cloud.utils.logger.Logger;
import org.json.JSONObject;
@@ -61,6 +63,8 @@ import im.zego.zegoexpress.entity.ZegoVideoFrameParam;
public class MoGoLiveManager {
public static final String TAG = "MoGoLiveManager";
//这个只是根据业务需求进行设置的变量,具体应用需根据开发者自定义安排。仅供参考
public static boolean isFirstLogin = true;
/**
* 即构平台分配 APP_ID
*/
@@ -217,10 +221,11 @@ public class MoGoLiveManager {
if (mLiveStatusModel.getCurrentRoomId().equals(roomID)) {
Log.i(TAG, "房间状态变化通知 onRoomStateUpdate currentRoomId : " + roomID +
" state:" + state +
" errorCode:" + errorCode);
" errorCode:" + errorCode +
" extendedData:" + extendedData.toString());
// 设置当前登录状态
mLiveStatusModel.setLoginCurrentRoom(state != ZegoRoomState.DISCONNECTED);
mLiveStatusModel.setLoginCurrentRoom(state != DISCONNECTED);
//房间状态更新
if (state == ZegoRoomState.CONNECTING) {
for (ILiveCurrentRoomStatusListener iLiveRoomStatusListener : mRoomStatusListener) {
@@ -231,19 +236,40 @@ public class MoGoLiveManager {
iLiveRoomStatusListener.onCurrentRoomConnected();
}
} else {
mLiveStatusModel.setLoginCurrentRoom(false);
for (ILiveCurrentRoomStatusListener iLiveRoomStatusListener : mRoomStatusListener) {
iLiveRoomStatusListener.onCurrentRoomDisconnected();
}
}
//errorCode 不为 0 时,房间状态异常,完整错误状态可参考错误码说明 https://doc-zh.zego.im/article/4378
// 处理被踢掉的情况
if (errorCode != 0) {
Logger.w(TAG, "用户被踢出房间,尝试再次登录……");
if (errorCode == 1002053) {
//房间连接断开并且重试超时
//此时可以在业务中退出房间/直播间/课堂,或者手动调用接口再次登录
loginRoom();
} else if (errorCode == 1002050) {
//用户被踢出房间(由于 userID 相同的用户在其他地方登录)
// 再次登录
loginRoom();
} else if (errorCode == 1002055) {
//用户被踢出房间(开发者主动调用后台的踢人接口)
} else if (errorCode == 1002033) {
//当使用登录房间鉴权的功能时,传入的 token 出错导
}
}
}
}
// 这里回调的是登录的他人房间的状态
if (mLiveStatusModel.getMultiRoomId().equals(roomID)) {
Log.i(TAG, "这里回调的是登录的他人房间的状态 onRoomStateUpdate multiRoomId : " + roomID +
" state:" + state +
" errorCode:" + errorCode);
" errorCode:" + errorCode +
" extendedData:" + extendedData.toString());
// 设置第二个房间登录状态
mLiveStatusModel.setLoginMultiRoom(state != ZegoRoomState.DISCONNECTED);
mLiveStatusModel.setLoginMultiRoom(state != DISCONNECTED);
//房间状态更新
if (state == ZegoRoomState.CONNECTING) {
for (ILiveMultiRoomStatusListener iLiveMultiRoomStatusListener : mMultiRoomStatusListener) {
@@ -319,7 +345,8 @@ public class MoGoLiveManager {
Log.i(TAG, "推流状态回调 onPublisherStateUpdate streamID : " + streamID +
" , isPushing : " + mLiveStatusModel.isPushing() +
" , state : " + state.name() +
" , errorCode : " + errorCode);
" , errorCode : " + errorCode +
" , extendedData : " + extendedData.toString());
// // 判断如果处于非播放和非推流状态则进行登出操作,并释放引擎
// if (!mLiveStatusModel.isPlaying()
@@ -377,7 +404,9 @@ public class MoGoLiveManager {
public void onPlayerRecvVideoFirstFrame(String streamID) {
super.onPlayerRecvVideoFirstFrame(streamID);
Log.d(TAG, "onPlayerRecvVideoFirstFrame");
if (mMediaPlayerStateListener != null) mMediaPlayerStateListener.onVideoFirstFrame();
if (mMediaPlayerStateListener != null) {
mMediaPlayerStateListener.onVideoFirstFrame();
}
}
@Override
@@ -493,16 +522,6 @@ public class MoGoLiveManager {
profile.application = mApplication;
/* 创建引擎 */
mExpressEngine = ZegoExpressEngine.createEngine(profile, mEventHandler);
// mExpressEngine = ZegoExpressEngine.createEngine(
// appId,
// appKey,
// isTestEnv,
// ZegoScenario.GENERAL,
// mApplication,
// mEventHandler);
// 关闭日志
//mExpressEngine.setDebugVerbose(MoGoAiCloudClientConfig.getInstance().isShowDebugLog(), ZegoLanguage.CHINESE);
// true 表示静音(关闭)
mExpressEngine.muteMicrophone(true);
if (mLivePushConfig != null) {

View File

@@ -27,25 +27,25 @@ SNAPSHOT_REPOSITORY_URL=http://nexus.zhidaoauto.com/repository/maven-snapshots/
USERNAME=xintai
PASSWORD=xintai2018
# 编译模式: false - 依赖本地版本, true - 依赖 maven 版本
RELEASE=false
RELEASE=true
# AI CLOUD 云平台
# 工具类
MOGO_UTILS_VERSION=1.1.62-live
MOGO_UTILS_VERSION=1.1.63
# 网络请求
MOGO_NETWORK_VERSION=1.1.62-live
MOGO_NETWORK_VERSION=1.1.63
# 网络DNS
MOGO_HTTPDNS_VERSION=1.1.62-live
MOGO_HTTPDNS_VERSION=1.1.63
# 鉴权
MOGO_PASSPORT_VERSION=1.1.62-live
MOGO_PASSPORT_VERSION=1.1.63
# 常链接
MOGO_SOCKET_VERSION=1.1.62-live
MOGO_SOCKET_VERSION=1.1.63
# 数据采集
MOGO_REALTIME_VERSION=1.1.62-live
MOGO_REALTIME_VERSION=1.1.63
# 探路,道路事件发布,获取
MOGO_TANLU_VERSION=1.1.62-live
MOGO_TANLU_VERSION=1.1.63
# 直播推流
MOGO_LIVE_VERSION=1.1.62-live
MOGO_LIVE_VERSION=1.1.63
# 直播拉流
MOGO_TRAFFICLIVE_VERSION=1.1.62-live
MOGO_TRAFFICLIVE_VERSION=1.1.63
# 定位服务
MOGO_LOCATION_VERSION=1.1.62-live
MOGO_LOCATION_VERSION=1.1.63