Commit e24b4567 by YKai

feat:日志优化

parent 913787af
...@@ -61,6 +61,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers ...@@ -61,6 +61,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers import io.reactivex.schedulers.Schedulers
import kotlinx.android.synthetic.main.audioim_activity_audio_home.* import kotlinx.android.synthetic.main.audioim_activity_audio_home.*
import java.util.*
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
/** /**
...@@ -146,7 +147,7 @@ class AudioHomeActivity : ...@@ -146,7 +147,7 @@ class AudioHomeActivity :
private var localRemainTime: Int? = 0 private var localRemainTime: Int? = 0
/** /**
* 60s自动挂断倒计时 * 50s自动挂断倒计时
*/ */
private var waitDisposable: Disposable? = null private var waitDisposable: Disposable? = null
...@@ -205,7 +206,6 @@ class AudioHomeActivity : ...@@ -205,7 +206,6 @@ class AudioHomeActivity :
uploadException("mRtcEventHandler-onWarning:warnCode--%${warn}", callback = null) uploadException("mRtcEventHandler-onWarning:warnCode--%${warn}", callback = null)
LogUtil.e("[agora]发生警告回调$warn") LogUtil.e("[agora]发生警告回调$warn")
writeAgoraLog("声网警告回调($warn)") writeAgoraLog("声网警告回调($warn)")
uploadLog()
//103:没有可用的频道资源。可能是因为服务端没法分配频道资源 //103:没有可用的频道资源。可能是因为服务端没法分配频道资源
//104:查找频道超时。在加入频道时 SDK 先要查找指定的频道,出现该警告一般是因为网络太差,连接不到服务器 //104:查找频道超时。在加入频道时 SDK 先要查找指定的频道,出现该警告一般是因为网络太差,连接不到服务器
//105:查找频道请求被服务器拒绝。服务器可能没有办法处理这个请求或请求是非法的 //105:查找频道请求被服务器拒绝。服务器可能没有办法处理这个请求或请求是非法的
...@@ -234,7 +234,6 @@ class AudioHomeActivity : ...@@ -234,7 +234,6 @@ class AudioHomeActivity :
super.onError(err) super.onError(err)
uploadException("mRtcEventHandler-onError:errorCode--%${err}", callback = null) uploadException("mRtcEventHandler-onError:errorCode--%${err}", callback = null)
writeAgoraLog("声网错误回调errorCode--%${err}") writeAgoraLog("声网错误回调errorCode--%${err}")
uploadLog()
//3:SDK 初始化失败。Agora 建议尝试以下处理方法 //3:SDK 初始化失败。Agora 建议尝试以下处理方法
//7:SDK 尚未初始化,就调用其 API。请确认在调用 API 之前已创建 RtcEngine 对象并完成初始化 //7:SDK 尚未初始化,就调用其 API。请确认在调用 API 之前已创建 RtcEngine 对象并完成初始化
//10:API 调用超时。有些 API 调用需要 SDK 返回结果,如果 SDK 处理时间过长,超过 10 秒没有返回,会出现此错误 //10:API 调用超时。有些 API 调用需要 SDK 返回结果,如果 SDK 处理时间过长,超过 10 秒没有返回,会出现此错误
...@@ -311,7 +310,6 @@ class AudioHomeActivity : ...@@ -311,7 +310,6 @@ class AudioHomeActivity :
override fun onRtcStats(stats: IRtcEngineEventHandler.RtcStats?) { override fun onRtcStats(stats: IRtcEngineEventHandler.RtcStats?) {
super.onRtcStats(stats) super.onRtcStats(stats)
writeAgoraLog("声网onRtcStats:users:${stats?.users}") writeAgoraLog("声网onRtcStats:users:${stats?.users}")
uploadLog()
// 不需要移动端做离开房间逻辑,服务端会判断进行踢人逻辑 // 不需要移动端做离开房间逻辑,服务端会判断进行踢人逻辑
//因为用户端直接加入了频道,防止该回调执行时,专家还未加入频道,因此在连接成功之后,才进行频道人数判断 //因为用户端直接加入了频道,防止该回调执行时,专家还未加入频道,因此在连接成功之后,才进行频道人数判断
// if (isConnectSuccess && null != stats?.users && stats.users == 1) { // if (isConnectSuccess && null != stats?.users && stats.users == 1) {
...@@ -636,10 +634,10 @@ class AudioHomeActivity : ...@@ -636,10 +634,10 @@ class AudioHomeActivity :
) )
sendDoctocrMsg = Gson().toJson(msgBean) sendDoctocrMsg = Gson().toJson(msgBean)
writeAgoraLog("主叫发送通话邀请") writeAgoraLog("主叫(用户)发送通话邀请")
rtcCall() rtcCall()
//开始60s等待倒计时 //开始50s等待倒计时
waitDisposable = waitDisposable =
Observable.interval(0, 100, TimeUnit.MILLISECONDS).subscribeOn(Schedulers.computation()) Observable.interval(0, 100, TimeUnit.MILLISECONDS).subscribeOn(Schedulers.computation())
.take(600).observeOn(AndroidSchedulers.mainThread()).subscribe({ .take(600).observeOn(AndroidSchedulers.mainThread()).subscribe({
...@@ -664,7 +662,7 @@ class AudioHomeActivity : ...@@ -664,7 +662,7 @@ class AudioHomeActivity :
if (!isConnectSuccess) { if (!isConnectSuccess) {
//关闭音乐 //关闭音乐
stopPlaying() stopPlaying()
writeAgoraLog("未接通挂断:60s等待倒计时结束挂断") writeAgoraLog("未接通挂断:50s等待倒计时结束挂断")
//提示切换传统线路 //提示切换传统线路
//发送消息通知专家用户已挂断 //发送消息通知专家用户已挂断
YDLavManager.instances.cancelCall( YDLavManager.instances.cancelCall(
...@@ -672,7 +670,7 @@ class AudioHomeActivity : ...@@ -672,7 +670,7 @@ class AudioHomeActivity :
channelId!!, channelId!!,
sendDoctocrMsg!! sendDoctocrMsg!!
) { msg, code -> ) { msg, code ->
writeAgoraLog("未接听时:主叫主动挂断失败,msg=$msg($code),再次挂断") writeAgoraLog("未接听时:主叫(用户)主动挂断失败,msg=$msg($code),再次挂断")
} }
//通话结束或挂断时,上传日志文件 //通话结束或挂断时,上传日志文件
uploadLog() uploadLog()
...@@ -707,7 +705,7 @@ class AudioHomeActivity : ...@@ -707,7 +705,7 @@ class AudioHomeActivity :
* 声网加入频道 * 声网加入频道
*/ */
fun joinChannel() { fun joinChannel() {
writeAgoraLog("对方接受了通话邀请,主叫开始加入频道:$channelId") writeAgoraLog("对方(专家)接受了通话邀请,主叫(用户)开始加入频道:$channelId")
voiceManage!!.getVoiceApi().joinChannel( voiceManage!!.getVoiceApi().joinChannel(
token!!, token!!,
channelId!!, channelId!!,
...@@ -722,7 +720,7 @@ class AudioHomeActivity : ...@@ -722,7 +720,7 @@ class AudioHomeActivity :
* *
*/ */
private fun userCloseCalling() { private fun userCloseCalling() {
writeAgoraLog("未接听时:主叫主动挂断,取消呼叫") writeAgoraLog("未接听时:主叫(用户)主动挂断,取消呼叫")
LogUtil.e("未接听挂断") LogUtil.e("未接听挂断")
//发送消息通知专家用户已挂断 //发送消息通知专家用户已挂断
YDLavManager.instances.cancelCall( YDLavManager.instances.cancelCall(
...@@ -730,7 +728,7 @@ class AudioHomeActivity : ...@@ -730,7 +728,7 @@ class AudioHomeActivity :
channelId!!, channelId!!,
sendDoctocrMsg!! sendDoctocrMsg!!
) { msg, code -> ) { msg, code ->
writeAgoraLog("未接听时:主叫主动挂断失败,msg=$msg($code),再次挂断") writeAgoraLog("未接听时:主叫(用户)主动挂断失败,msg=$msg($code),再次挂断")
} }
//通话结束或挂断时,上传日志文件 //通话结束或挂断时,上传日志文件
uploadLog() uploadLog()
...@@ -1201,7 +1199,7 @@ class AudioHomeActivity : ...@@ -1201,7 +1199,7 @@ class AudioHomeActivity :
fun writeAgoraLog(content: String, isAppend: Boolean = true) { fun writeAgoraLog(content: String, isAppend: Boolean = true) {
try { try {
AudioLogUtils.writeAgoraLog(content, "confide", isAppend) AudioLogUtils.writeAgoraLog("$content-------Time:${AudioLogUtils.format.format(Calendar.getInstance().time)}", "confide.log", isAppend)
} catch (e: Exception) { } catch (e: Exception) {
} }
} }
......
...@@ -37,6 +37,7 @@ import io.agora.rtm.RtmStatusCode ...@@ -37,6 +37,7 @@ import io.agora.rtm.RtmStatusCode
import io.reactivex.Observable import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers import io.reactivex.schedulers.Schedulers
import java.util.*
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
/** /**
...@@ -47,7 +48,7 @@ import java.util.concurrent.TimeUnit ...@@ -47,7 +48,7 @@ import java.util.concurrent.TimeUnit
class YDLavManager { class YDLavManager {
companion object { companion object {
const val FILE_NAME = "consult" const val FILE_NAME = "consult.log"
//当前sdk的登录状态 //当前sdk的登录状态
var sdkStatus = -1 var sdkStatus = -1
...@@ -118,7 +119,7 @@ class YDLavManager { ...@@ -118,7 +119,7 @@ class YDLavManager {
act.runOnUiThread { act.runOnUiThread {
callEndStatusUpdate(response?.ChannelId!!, 2, "被叫拒绝") callEndStatusUpdate(response?.ChannelId!!, 2, "被叫拒绝")
ToastUtil.toastShort("对方已挂断") ToastUtil.toastShort("对方已挂断")
act.writeAgoraLog("被叫拒绝了通话邀请") act.writeAgoraLog("被叫(专家)拒绝了通话邀请")
//通话结束或挂断时,上传日志文件 //通话结束或挂断时,上传日志文件
act.uploadLog() act.uploadLog()
act.leaveChannel() act.leaveChannel()
...@@ -133,7 +134,7 @@ class YDLavManager { ...@@ -133,7 +134,7 @@ class YDLavManager {
val act = ActivityManager.getInstance().getTopTaskActivity() val act = ActivityManager.getInstance().getTopTaskActivity()
if (act is AudioHomeActivity) { if (act is AudioHomeActivity) {
act.runOnUiThread { act.runOnUiThread {
act.writeAgoraLog("主叫呼叫取消:超时或主动取消") act.writeAgoraLog("主叫(用户)呼叫取消:超时或主动取消")
act.uploadExceptionStatus("已取消", 1) act.uploadExceptionStatus("已取消", 1)
} }
} }
...@@ -162,7 +163,7 @@ class YDLavManager { ...@@ -162,7 +163,7 @@ class YDLavManager {
"5" "5"
) )
callEndStatusUpdate(response.ChannelId!!, 2, "被叫超时未接听") callEndStatusUpdate(response.ChannelId!!, 2, "被叫超时未接听")
act.writeAgoraLog("呼叫失败:${errorCode}") act.writeAgoraLog("用户呼叫失败:${errorCode}")
act.uploadExceptionStatus("对方未接听", 3) act.uploadExceptionStatus("对方未接听", 3)
// //通话结束或挂断时,上传日志文件 // //通话结束或挂断时,上传日志文件
// act.uploadLog() // act.uploadLog()
...@@ -197,7 +198,7 @@ class YDLavManager { ...@@ -197,7 +198,7 @@ class YDLavManager {
callEndStatusUpdate(response?.ChannelId!!, 1, "主叫取消呼叫") callEndStatusUpdate(response?.ChannelId!!, 1, "主叫取消呼叫")
//返回给被叫 //返回给被叫
LogUtil.e("[agora]主叫${response?.callerId}已取消呼叫邀请") LogUtil.e("[agora]主叫${response?.callerId}已取消呼叫邀请")
AudioLogUtils.writeAgoraLog("呼叫邀请被取消:主叫主动取消", FILE_NAME) writeAgoraLog("呼叫邀请被取消:主叫(专家)主动取消-------Time:${AudioLogUtils.format.format(Calendar.getInstance().time)}", FILE_NAME)
val act = ActivityManager.getInstance().getTopTaskActivity() val act = ActivityManager.getInstance().getTopTaskActivity()
if (act is ConsultantAudioHomeActivity) { if (act is ConsultantAudioHomeActivity) {
...@@ -211,13 +212,13 @@ class YDLavManager { ...@@ -211,13 +212,13 @@ class YDLavManager {
//返回给被叫 //返回给被叫
LogUtil.e("[agora]来自主叫${response?.callerId}的呼叫邀请进程失败:${response?.response}") LogUtil.e("[agora]来自主叫${response?.callerId}的呼叫邀请进程失败:${response?.response}")
if (errorCode == RtmStatusCode.RemoteInvitationError.REMOTE_INVITATION_ERR_INVITATION_EXPIRE) { //呼叫邀请过期 if (errorCode == RtmStatusCode.RemoteInvitationError.REMOTE_INVITATION_ERR_INVITATION_EXPIRE) { //呼叫邀请过期
AudioLogUtils.writeAgoraLog("呼叫邀请被取消:呼叫邀请过期", FILE_NAME) writeAgoraLog("呼叫邀请被取消:用户未接听-------Time:${AudioLogUtils.format.format(Calendar.getInstance().time)}", FILE_NAME)
val act = ActivityManager.getInstance().getTopTaskActivity() val act = ActivityManager.getInstance().getTopTaskActivity()
if (act is ConsultantAudioHomeActivity) { if (act is ConsultantAudioHomeActivity) {
act.uploadExceptionStatus("未接听", 3) act.uploadExceptionStatus("未接听", 3)
} }
} else { } else {
AudioLogUtils.writeAgoraLog("呼叫邀请被取消:错误原因(${errorCode})", FILE_NAME) writeAgoraLog("呼叫邀请被取消:错误原因(${errorCode})-------Time:${AudioLogUtils.format.format(Calendar.getInstance().time)}", FILE_NAME)
} }
callEndStatusUpdate(response?.ChannelId!!, 2, "超时未接听导致的取消呼叫") callEndStatusUpdate(response?.ChannelId!!, 2, "超时未接听导致的取消呼叫")
//关闭页面 //关闭页面
...@@ -242,13 +243,11 @@ class YDLavManager { ...@@ -242,13 +243,11 @@ class YDLavManager {
//1发起呼叫 2接受呼叫 3取消呼叫 4拒绝呼叫邀请 5呼叫超时 //1发起呼叫 2接受呼叫 3取消呼叫 4拒绝呼叫邀请 5呼叫超时
when (agoraInvitationBean.callType) { when (agoraInvitationBean.callType) {
"1" -> { "1" -> {
writeAgoraLog("1收到云信消息通知电话", FILE_NAME) writeAgoraLog("1收到云信消息通知电话-------Time:${AudioLogUtils.format.format(Calendar.getInstance().time)}", FILE_NAME)
LogHelper.getInstance().uploadLog(false)
receivedCall(agoraInvitationBean.data, "来自云信") receivedCall(agoraInvitationBean.data, "来自云信")
} }
"2" -> { "2" -> {
writeAgoraLog( writeAgoraLog("对方接受了通话邀请,主叫开始加入频道:callType${agoraInvitationBean.callType}-------Time:${AudioLogUtils.format.format(Calendar.getInstance().time)}",
"对方接受了通话邀请,主叫开始加入频道:callType${agoraInvitationBean.callType}",
FILE_NAME FILE_NAME
) )
val act = ActivityManager.getInstance().getTopTaskActivity() val act = ActivityManager.getInstance().getTopTaskActivity()
...@@ -259,11 +258,11 @@ class YDLavManager { ...@@ -259,11 +258,11 @@ class YDLavManager {
} }
} }
"3" -> { "3" -> {
writeAgoraLog("呼叫邀请被取消:主叫主动取消", FILE_NAME) writeAgoraLog("呼叫邀请被取消:主叫主动取消-------Time:${AudioLogUtils.format.format(Calendar.getInstance().time)}", FILE_NAME)
closePage() closePage()
} }
"4" -> { "4" -> {
writeAgoraLog("被叫拒绝了通话邀请", FILE_NAME) writeAgoraLog("被叫拒绝了通话邀请-------Time:${AudioLogUtils.format.format(Calendar.getInstance().time)}", FILE_NAME)
val act = ActivityManager.getInstance().getTopTaskActivity() val act = ActivityManager.getInstance().getTopTaskActivity()
if (act is AudioHomeActivity) { if (act is AudioHomeActivity) {
act.runOnUiThread { act.runOnUiThread {
...@@ -275,15 +274,12 @@ class YDLavManager { ...@@ -275,15 +274,12 @@ class YDLavManager {
} }
} }
"5" -> { "5" -> {
writeAgoraLog("呼叫邀请被取消:呼叫邀请过期", FILE_NAME) writeAgoraLog("呼叫邀请被取消:呼叫邀请过期-------Time:${AudioLogUtils.format.format(Calendar.getInstance().time)}", FILE_NAME)
//关闭页面 //关闭页面
closePage() closePage()
} }
else -> { else -> {
writeAgoraLog( writeAgoraLog("其它AgoraInvitationBean,${agoraInvitationBean.callType}-------Time:${AudioLogUtils.format.format(Calendar.getInstance().time)}", FILE_NAME)
"其它AgoraInvitationBean,${agoraInvitationBean.callType}",
FILE_NAME
)
} }
} }
} }
...@@ -407,18 +403,21 @@ class YDLavManager { ...@@ -407,18 +403,21 @@ class YDLavManager {
Observable.timer(1000, TimeUnit.MILLISECONDS).subscribeOn(Schedulers.io()) Observable.timer(1000, TimeUnit.MILLISECONDS).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()).subscribe { .observeOn(AndroidSchedulers.mainThread()).subscribe {
LogUtil.e("[agora]启动通话界面") LogUtil.e("[agora]启动通话界面")
writeAgoraLog("收到主叫方通话邀请($from)", FILE_NAME, false) writeAgoraLog("收到主叫方通话邀请($from)-------Time:${AudioLogUtils.format.format(Calendar.getInstance().time)}", FILE_NAME, false)
LogHelper.getInstance().uploadLog(false)
//邀请加入频道消息,跳转通话界面 //邀请加入频道消息,跳转通话界面
ARouter.getInstance().build("/av/ConsultantAudioHomeActivity") ARouter.getInstance().build("/av/ConsultantAudioHomeActivity")
.withString("param", content).navigation() .withString("param", content).navigation()
} }
} else { } else {
LogUtil.d("[agora]收到声网邀请,但界面实例已存在") LogUtil.d("[agora]收到声网邀请,但界面实例已存在")
writeAgoraLog("收到主叫方通话邀请,但界面实例已存在($from)", FILE_NAME, false) writeAgoraLog("收到主叫方通话邀请,但界面实例已存在($from)-------Time:${AudioLogUtils.format.format(Calendar.getInstance().time)}", FILE_NAME, false)
LogHelper.getInstance().uploadLog(false)
} }
} else { } else {
LogUtil.d("[agora]收到声网邀请,但response==null") LogUtil.d("[agora]收到声网邀请,但response==null")
writeAgoraLog("收到主叫方通话邀请,但response==null($from)", FILE_NAME, false) writeAgoraLog("收到主叫方通话邀请,但response==null($from)-------Time:${AudioLogUtils.format.format(Calendar.getInstance().time)}", FILE_NAME, false)
LogHelper.getInstance().uploadLog(false)
} }
} }
......
...@@ -27,7 +27,7 @@ import java.util.* ...@@ -27,7 +27,7 @@ import java.util.*
class AudioLogUtils { class AudioLogUtils {
companion object { companion object {
@SuppressLint("SimpleDateFormat") @SuppressLint("SimpleDateFormat")
private val format = SimpleDateFormat("yyyy-MM-dd HH:mm:ss") val format = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
fun writeAgoraLog(content: String, fileName: String, isAppend: Boolean = true) { fun writeAgoraLog(content: String, fileName: String, isAppend: Boolean = true) {
Observable.create<Any> { Observable.create<Any> {
......
...@@ -58,11 +58,12 @@ import io.reactivex.android.schedulers.AndroidSchedulers ...@@ -58,11 +58,12 @@ import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers import io.reactivex.schedulers.Schedulers
import kotlinx.android.synthetic.main.audioim_cativity_consultant_audio_home.* import kotlinx.android.synthetic.main.audioim_cativity_consultant_audio_home.*
import java.util.*
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
/** /**
* @author jiucheng * @author jiucheng
* @描述: 咨询声网通话页面(接受电话界面) * @描述: 咨询声网通话页面(用户接受电话界面)
* @Copyright Copyright (c) 2018 * @Copyright Copyright (c) 2018
* @Company 壹点灵 * @Company 壹点灵
* @date 2018/10/30 * @date 2018/10/30
...@@ -135,7 +136,7 @@ class ConsultantAudioHomeActivity : ...@@ -135,7 +136,7 @@ class ConsultantAudioHomeActivity :
override fun onJoinChannelSuccess(channel: String?, uid: Int, elapsed: Int) { override fun onJoinChannelSuccess(channel: String?, uid: Int, elapsed: Int) {
super.onJoinChannelSuccess(channel, uid, elapsed) super.onJoinChannelSuccess(channel, uid, elapsed)
LogUtil.e("[agora]$uid 加入频道回调") LogUtil.e("[agora]$uid 加入频道回调")
writeAgoraLog("被叫加入声网($channel)频道成功") writeAgoraLog("被叫(用户)加入声网($channel)频道成功")
runOnUiThread { runOnUiThread {
// 加入频道后再通知用户已接受 // 加入频道后再通知用户已接受
...@@ -164,7 +165,7 @@ class ConsultantAudioHomeActivity : ...@@ -164,7 +165,7 @@ class ConsultantAudioHomeActivity :
override fun onRejoinChannelSuccess(channel: String?, uid: Int, elapsed: Int) { override fun onRejoinChannelSuccess(channel: String?, uid: Int, elapsed: Int) {
super.onRejoinChannelSuccess(channel, uid, elapsed) super.onRejoinChannelSuccess(channel, uid, elapsed)
LogUtil.e("[agora]$uid 重新加入频道回调") LogUtil.e("[agora]$uid 重新加入频道回调")
writeAgoraLog("被叫重新加入声网频道($channel)成功") writeAgoraLog("被叫(用户)重新加入声网频道($channel)成功")
runOnUiThread { runOnUiThread {
if (!isConnectSuccess) { if (!isConnectSuccess) {
tv_toast.visibility = View.VISIBLE tv_toast.visibility = View.VISIBLE
...@@ -182,7 +183,7 @@ class ConsultantAudioHomeActivity : ...@@ -182,7 +183,7 @@ class ConsultantAudioHomeActivity :
override fun onUserJoined(uid: Int, elapsed: Int) { override fun onUserJoined(uid: Int, elapsed: Int) {
super.onUserJoined(uid, elapsed) super.onUserJoined(uid, elapsed)
LogUtil.e("[agora]远端用户加入频道回调") LogUtil.e("[agora]远端用户加入频道回调")
writeAgoraLog("主叫加入声网频道成功") writeAgoraLog("主叫(专家)加入声网频道成功")
//另一方加入频道成功 //另一方加入频道成功
runOnUiThread { runOnUiThread {
isConnectSuccess = true isConnectSuccess = true
...@@ -208,7 +209,7 @@ class ConsultantAudioHomeActivity : ...@@ -208,7 +209,7 @@ class ConsultantAudioHomeActivity :
"服务端踢人触发的回调" "服务端踢人触发的回调"
) )
writeAgoraLog("通话挂断:网络连接被服务器中止") writeAgoraLog("通话挂断:网络连接被服务器(后端)中止")
//通话结束或挂断时,上传日志文件 //通话结束或挂断时,上传日志文件
uploadLog() uploadLog()
leaveChannel() leaveChannel()
...@@ -224,8 +225,6 @@ class ConsultantAudioHomeActivity : ...@@ -224,8 +225,6 @@ class ConsultantAudioHomeActivity :
override fun onLeaveChannel(stats: IRtcEngineEventHandler.RtcStats?) { override fun onLeaveChannel(stats: IRtcEngineEventHandler.RtcStats?) {
super.onLeaveChannel(stats) super.onLeaveChannel(stats)
LogUtil.e("[agora]自己离开频道回调") LogUtil.e("[agora]自己离开频道回调")
//通话结束或挂断时,上传日志文件
uploadLog()
runOnUiThread { runOnUiThread {
//通知php 通话已结束 //通知php 通话已结束
close(RESULT_ANSWERED_CODE, "") close(RESULT_ANSWERED_CODE, "")
...@@ -253,9 +252,7 @@ class ConsultantAudioHomeActivity : ...@@ -253,9 +252,7 @@ class ConsultantAudioHomeActivity :
"对方离开频道" "对方离开频道"
) )
showToast("对方已挂断") showToast("对方已挂断")
writeAgoraLog("通话接通后挂断:主叫离开频道") writeAgoraLog("通话接通后挂断:主叫(专家)离开频道")
//通话结束或挂断时,上传日志文件
uploadLog()
if (null != totalDisposable) { if (null != totalDisposable) {
totalDisposable!!.dispose() totalDisposable!!.dispose()
} }
...@@ -271,8 +268,7 @@ class ConsultantAudioHomeActivity : ...@@ -271,8 +268,7 @@ class ConsultantAudioHomeActivity :
uploadException("mRtcEventHandler-onWarning:warnCode--%${warn}") uploadException("mRtcEventHandler-onWarning:warnCode--%${warn}")
} }
LogUtil.e("[agora]发生警告回调=$warn") LogUtil.e("[agora]发生警告回调=$warn")
writeAgoraLog("声网警告回调($warn)") writeAgoraLog("声网警告回调码:($warn)")
uploadLog()
//103:没有可用的频道资源。可能是因为服务端没法分配频道资源 //103:没有可用的频道资源。可能是因为服务端没法分配频道资源
//104:查找频道超时。在加入频道时 SDK 先要查找指定的频道,出现该警告一般是因为网络太差,连接不到服务器 //104:查找频道超时。在加入频道时 SDK 先要查找指定的频道,出现该警告一般是因为网络太差,连接不到服务器
//105:查找频道请求被服务器拒绝。服务器可能没有办法处理这个请求或请求是非法的 //105:查找频道请求被服务器拒绝。服务器可能没有办法处理这个请求或请求是非法的
...@@ -298,7 +294,6 @@ class ConsultantAudioHomeActivity : ...@@ -298,7 +294,6 @@ class ConsultantAudioHomeActivity :
uploadException("mRtcEventHandler-onError:errorCode--%${err}") uploadException("mRtcEventHandler-onError:errorCode--%${err}")
LogUtil.e("[agora] 发生错误回调 =$err") LogUtil.e("[agora] 发生错误回调 =$err")
writeAgoraLog("声网错误回调errorCode--%${err}") writeAgoraLog("声网错误回调errorCode--%${err}")
uploadLog()
//3:SDK 初始化失败。Agora 建议尝试以下处理方法 //3:SDK 初始化失败。Agora 建议尝试以下处理方法
//7:SDK 尚未初始化,就调用其 API。请确认在调用 API 之前已创建 RtcEngine 对象并完成初始化 //7:SDK 尚未初始化,就调用其 API。请确认在调用 API 之前已创建 RtcEngine 对象并完成初始化
...@@ -599,8 +594,6 @@ class ConsultantAudioHomeActivity : ...@@ -599,8 +594,6 @@ class ConsultantAudioHomeActivity :
} }
override fun executeFinish() { override fun executeFinish() {
//通话结束或挂断时,上传日志文件
uploadLog()
showToast("对方已挂断") showToast("对方已挂断")
close(RESULT_ANSWERED_CODE, "") close(RESULT_ANSWERED_CODE, "")
} }
...@@ -619,8 +612,6 @@ class ConsultantAudioHomeActivity : ...@@ -619,8 +612,6 @@ class ConsultantAudioHomeActivity :
.observeOn(AndroidSchedulers.mainThread()).subscribe({ .observeOn(AndroidSchedulers.mainThread()).subscribe({
tv_remain_time.text = DateUtils.formatTime(it.toString()) tv_remain_time.text = DateUtils.formatTime(it.toString())
}, { }, {
//通话结束或挂断时,上传日志文件
uploadLog()
close(RESULT_NOT_ANSWERED_CODE, "对方异常") close(RESULT_NOT_ANSWERED_CODE, "对方异常")
}) })
} }
...@@ -635,9 +626,7 @@ class ConsultantAudioHomeActivity : ...@@ -635,9 +626,7 @@ class ConsultantAudioHomeActivity :
private fun showStopService() { private fun showStopService() {
if (status == STATUS_NOT_ANSWERED) { if (status == STATUS_NOT_ANSWERED) {
YDLavManager.instances.callEndStatusUpdate(mAudioMessageBean?.channelId!!, 2, "被叫主动拒绝") YDLavManager.instances.callEndStatusUpdate(mAudioMessageBean?.channelId!!, 2, "被叫主动拒绝")
writeAgoraLog("通话未接通挂断:主动挂断") writeAgoraLog("通话未接通挂断:用户主动挂断")
//通话结束或挂断时,上传日志文件
uploadLog()
//当未接听 直接挂断 要发送给老师一条消息 //当未接听 直接挂断 要发送给老师一条消息
close(RESULT_NOT_ANSWERED_CODE, "用户已挂断") close(RESULT_NOT_ANSWERED_CODE, "用户已挂断")
} else if (status == STATUS_ANSWERED) { } else if (status == STATUS_ANSWERED) {
...@@ -821,6 +810,8 @@ class ConsultantAudioHomeActivity : ...@@ -821,6 +810,8 @@ class ConsultantAudioHomeActivity :
fun close(code: Int, msg: String) { fun close(code: Int, msg: String) {
runOnUiThread { runOnUiThread {
LogUtil.e("[agora]close(code:$code,msg:$msg)") LogUtil.e("[agora]close(code:$code,msg:$msg)")
//上传日志文件
uploadLog()
stopMusic() stopMusic()
//播放结束音频 //播放结束音频
playFinishMusic() playFinishMusic()
...@@ -956,7 +947,7 @@ class ConsultantAudioHomeActivity : ...@@ -956,7 +947,7 @@ class ConsultantAudioHomeActivity :
private fun writeAgoraLog(content: String) { private fun writeAgoraLog(content: String) {
Observable.create<Any> { Observable.create<Any> {
try { try {
AudioLogUtils.writeAgoraLog(content, "consult") AudioLogUtils.writeAgoraLog("$content-------Time:${AudioLogUtils.format.format(Calendar.getInstance().time)}", "consult.log")
} catch (e: Exception) { } catch (e: Exception) {
} }
}.subscribeOn(Schedulers.io()).subscribe() }.subscribeOn(Schedulers.io()).subscribe()
......
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