Commit b9e2abb3 by YKai

feat:声网onWaring返回警告,离开房间代码注释,增加日志上传

parent 919ca7e5
......@@ -65,7 +65,7 @@ import java.util.concurrent.TimeUnit
/**
* @author jiucheng
* @描述: 倾诉声网通话页面
* @描述: 倾诉声网通话页面(拨打电话界面)
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/10/30
......@@ -188,22 +188,23 @@ class AudioHomeActivity :
//106:打开频道超时。查找到指定频道后,SDK 接着打开该频道,超时一般是因为网络太差,连接不到服务器
//107:打开频道请求被服务器拒绝。服务器可能没有办法处理该请求或该请求是非法的
LogUtil.e("[agora]发生警告回调$warn")
runOnUiThread {
when (warn) {
103, 105, 107 -> {
writeAgoraLog("通话挂断:网络异常(${warn})")
showToast("当前网络较差,请更换网络!")
//通话结束或挂断时,上传日志文件
uploadLog()
leaveChannel()
YDLavManager.instances.callEndStatusUpdate(
channelId!!,
4,
"收到频道回调警告信息$warn"
)
}
}
}
// 声网发出警告错误码,不应该直接离开房间
// runOnUiThread {
// when (warn) {
// 103, 105, 107 -> {
// writeAgoraLog("通话挂断:网络异常(${warn})")
// showToast("当前网络较差,请更换网络!")
// //通话结束或挂断时,上传日志文件
// uploadLog()
// leaveChannel()
// YDLavManager.instances.callEndStatusUpdate(
// channelId!!,
// 4,
// "收到频道回调警告信息$warn"
// )
// }
// }
// }
}
override fun onError(err: Int) {
......
......@@ -11,6 +11,7 @@ import com.ydl.audioim.http.AudioApiRequestUtil
import com.ydl.audioim.http.command.ConnectExceptionCommand
import com.ydl.audioim.router.AudioImIn
import com.ydl.audioim.utils.AudioLogUtils
import com.ydl.audioim.utils.AudioLogUtils.Companion.writeAgoraLog
import com.ydl.consultantim.ConsultantAudioHomeActivity
import com.ydl.ydl_av.messge_service.YDLRTMClient
import com.ydl.ydl_av.messge_service.bean.RTMMesssage
......@@ -47,6 +48,7 @@ class YDLavManager {
companion object {
const val FILE_NAME = "consult"
//当前sdk的登录状态
var sdkStatus = -1
......@@ -240,9 +242,14 @@ class YDLavManager {
//1发起呼叫 2接受呼叫 3取消呼叫 4拒绝呼叫邀请 5呼叫超时
when (agoraInvitationBean.callType) {
"1" -> {
writeAgoraLog("1收到云信消息通知电话", FILE_NAME)
receivedCall(agoraInvitationBean.data, "来自云信")
}
"2" -> {
writeAgoraLog(
"对方接受了通话邀请,主叫开始加入频道:callType${agoraInvitationBean.callType}",
FILE_NAME
)
val act = ActivityManager.getInstance().getTopTaskActivity()
if (act is AudioHomeActivity) {
act.runOnUiThread {
......@@ -251,15 +258,15 @@ class YDLavManager {
}
}
"3" -> {
AudioLogUtils.writeAgoraLog("呼叫邀请被取消:主叫主动取消", FILE_NAME)
writeAgoraLog("呼叫邀请被取消:主叫主动取消", FILE_NAME)
closePage()
}
"4" -> {
writeAgoraLog("被叫拒绝了通话邀请", FILE_NAME)
val act = ActivityManager.getInstance().getTopTaskActivity()
if (act is AudioHomeActivity) {
act.runOnUiThread {
ToastUtil.toastShort("对方已挂断")
act.writeAgoraLog("被叫拒绝了通话邀请")
//通话结束或挂断时,上传日志文件
act.uploadLog()
act.leaveChannel()
......@@ -267,10 +274,16 @@ class YDLavManager {
}
}
"5" -> {
AudioLogUtils.writeAgoraLog("呼叫邀请被取消:呼叫邀请过期", FILE_NAME)
writeAgoraLog("呼叫邀请被取消:呼叫邀请过期", FILE_NAME)
//关闭页面
closePage()
}
else -> {
writeAgoraLog(
"其它AgoraInvitationBean,${agoraInvitationBean.callType}",
FILE_NAME
)
}
}
}
})
......@@ -393,17 +406,18 @@ class YDLavManager {
Observable.timer(1000, TimeUnit.MILLISECONDS).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()).subscribe {
LogUtil.e("[agora]启动通话界面")
writeAgoraLog("收到主叫方通话邀请($from)", FILE_NAME, false)
//邀请加入频道消息,跳转通话界面
ARouter.getInstance().build("/av/ConsultantAudioHomeActivity")
.withString("param", content).navigation()
AudioLogUtils.writeAgoraLog("收到主叫方通话邀请($from)", FILE_NAME, false)
}
} else {
LogUtil.d("[agora]收到声网邀请,但界面实例已存在")
writeAgoraLog("收到主叫方通话邀请,但界面实例已存在($from)", FILE_NAME, false)
}
} else {
LogUtil.d("[agora]收到声网邀请,但response==null")
writeAgoraLog("收到主叫方通话邀请,但response==null($from)", FILE_NAME, false)
}
}
......@@ -489,7 +503,9 @@ class YDLavManager {
override fun onTokenExpired() {
LogUtil.e("[agora]onTokenExpired")
instances.login(ModularServiceManager.provide(IUserService::class.java).getUserInfo()?.uid)
instances.login(
ModularServiceManager.provide(IUserService::class.java).getUserInfo()?.uid
)
}
override fun onMessageReceived(message: RTMMesssage, userId: Int) {
......
......@@ -62,7 +62,7 @@ import java.util.concurrent.TimeUnit
/**
* @author jiucheng
* @描述: 咨询声网通话页面
* @描述: 咨询声网通话页面(接受电话界面)
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/10/30
......@@ -255,18 +255,19 @@ class ConsultantAudioHomeActivity : BaseMvpActivity<IConsultantAudioHomeActivity
//105:查找频道请求被服务器拒绝。服务器可能没有办法处理这个请求或请求是非法的
//106:打开频道超时。查找到指定频道后,SDK 接着打开该频道,超时一般是因为网络太差,连接不到服务器
//107:打开频道请求被服务器拒绝。服务器可能没有办法处理该请求或该请求是非法的
runOnUiThread {
when (warn) {
103, 105, 107 -> {
YDLavManager.instances.callEndStatusUpdate(mAudioMessageBean?.channelId!!, 4, "收到频道回调警告信息${warn}")
writeAgoraLog("通话挂断:网络异常($warn)")
showToast("当前网络较差,请更换网络!")
//通话结束或挂断时,上传日志文件
uploadLog()
close(RESULT_NOT_ANSWERED_CODE, "[agora]专家网络较差")
}
}
}
// 声网发出警告错误码,不应该直接离开房间
// runOnUiThread {
// when (warn) {
// 103, 105, 107 -> {
// YDLavManager.instances.callEndStatusUpdate(mAudioMessageBean?.channelId!!, 4, "收到频道回调警告信息${warn}")
// writeAgoraLog("通话挂断:网络异常($warn)")
// showToast("当前网络较差,请更换网络!")
// //通话结束或挂断时,上传日志文件
// uploadLog()
// close(RESULT_NOT_ANSWERED_CODE, "[agora]专家网络较差")
// }
// }
// }
}
override fun onError(err: Int) {
......@@ -291,7 +292,7 @@ class ConsultantAudioHomeActivity : BaseMvpActivity<IConsultantAudioHomeActivity
showToast("请退出应用,重新打开")
close(RESULT_NOT_ANSWERED_CODE, "咨询师已挂断")
}
10, 17 -> {
10 -> {
showToast("当前网络较差,请更换网络")
close(RESULT_NOT_ANSWERED_CODE, "专家网络较差")
}
......@@ -758,20 +759,24 @@ class ConsultantAudioHomeActivity : BaseMvpActivity<IConsultantAudioHomeActivity
stopMusic()
//播放结束音频
playFinishMusic()
if (code == RESULT_ANSWERED_CODE) {
//已接听,正常挂断
//离开频道
leaveChannel()
} else if (code == RESULT_NOT_ANSWERED_CODE) {
callStatus = 2
uploadException("被叫拒绝", zhu = "")
//未接听,直接挂断 发送消息
// YDLRTMClient.instances.refuseCall(mAudioMessageBean?.channelId)
YDLavManager.instances.refuseCall(mAudioMessageBean!!.userId!!, mAudioMessageBean?.channelId, Gson().toJson(mAudioMessageBean))
} else if (code == RESULT_USER_CANCEL) {
callStatus = 1
uploadException("主叫取消", zhu = "")
showToast("对方已挂断")
when (code) {
RESULT_ANSWERED_CODE -> {
//已接听,正常挂断
//离开频道
leaveChannel()
}
RESULT_NOT_ANSWERED_CODE -> {
callStatus = 2
uploadException("被叫拒绝", zhu = "")
//未接听,直接挂断 发送消息
// YDLRTMClient.instances.refuseCall(mAudioMessageBean?.channelId)
YDLavManager.instances.refuseCall(mAudioMessageBean!!.userId!!, mAudioMessageBean?.channelId, Gson().toJson(mAudioMessageBean))
}
RESULT_USER_CANCEL -> {
callStatus = 1
uploadException("主叫取消", zhu = "")
showToast("对方已挂断")
}
}
ActivityManager.getInstance().removeStack(activity = this)
LogUtil.e("[agora]页面移除")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment