Commit ebe6578a by 严久程

接口参数

parent 6e4790e1
...@@ -5,7 +5,7 @@ ext { ...@@ -5,7 +5,7 @@ ext {
ydlPublishVersion = [ ydlPublishVersion = [
// -------------- 业务模块 -------------- // -------------- 业务模块 --------------
//第三步 若干 //第三步 若干
"m-confide" : "0.0.48.43", "m-confide" : "0.0.48.47",
"m-consultant" : "0.0.59.10", "m-consultant" : "0.0.59.10",
"m-fm" : "0.0.29.9", "m-fm" : "0.0.29.9",
"m-user" : "0.0.60.8", "m-user" : "0.0.60.8",
...@@ -39,7 +39,7 @@ ext { ...@@ -39,7 +39,7 @@ ext {
"ydl-webview" : "0.0.38.31", "ydl-webview" : "0.0.38.31",
"ydl-media" : "0.0.21.6", "ydl-media" : "0.0.21.6",
"ydl-pay" : "0.0.18.9", "ydl-pay" : "0.0.18.9",
"m-audioim" : "0.0.49.16", "m-audioim" : "0.0.49.21",
"ydl-flutter-base": "0.0.14.14", "ydl-flutter-base": "0.0.14.14",
//以下 几乎不会动 //以下 几乎不会动
...@@ -122,7 +122,7 @@ ext { ...@@ -122,7 +122,7 @@ ext {
"ydl-webview" : "0.0.38.31", "ydl-webview" : "0.0.38.31",
"ydl-media" : "0.0.21.6", "ydl-media" : "0.0.21.6",
"ydl-pay" : "0.0.18.9", "ydl-pay" : "0.0.18.9",
"m-audioim" : "0.0.49.16", "m-audioim" : "0.0.49.21",
"ydl-flutter-base": "0.0.14.14", "ydl-flutter-base": "0.0.14.14",
//以下 几乎不会动 //以下 几乎不会动
......
...@@ -71,7 +71,9 @@ import java.util.concurrent.TimeUnit ...@@ -71,7 +71,9 @@ import java.util.concurrent.TimeUnit
* @date 2018/10/30 * @date 2018/10/30
*/ */
@Route(path = "/av/AudioHomeActivity") @Route(path = "/av/AudioHomeActivity")
class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudioHomeActivityContract.Presenter>(), IAudioHomeActivityContract.View, SensorEventListener { class AudioHomeActivity :
BaseMvpActivity<IAudioHomeActivityContract.View, IAudioHomeActivityContract.Presenter>(),
IAudioHomeActivityContract.View, SensorEventListener {
/** /**
* 专家头像地址 * 专家头像地址
...@@ -189,7 +191,11 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -189,7 +191,11 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
runOnUiThread { runOnUiThread {
when (warn) { when (warn) {
103, 105, 107 -> { 103, 105, 107 -> {
YDLavManager.instances.callEndStatusUpdate(channelId!!, 4, "收到频道回调警告信息$warn") YDLavManager.instances.callEndStatusUpdate(
channelId!!,
4,
"收到频道回调警告信息$warn"
)
writeAgoraLog("通话挂断:网络异常(${warn})") writeAgoraLog("通话挂断:网络异常(${warn})")
showToast("当前网络较差,请更换网络!") showToast("当前网络较差,请更换网络!")
...@@ -244,7 +250,7 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -244,7 +250,7 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
leaveChannel() leaveChannel()
} }
} }
YDLavManager.instances.callEndStatusUpdate(channelId!!, 4, "频道的错误回调信息$err") YDLavManager.instances.callEndStatusUpdate(channelId!!, 4, "频道的错误回调信息$err")
} }
} }
...@@ -327,7 +333,7 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -327,7 +333,7 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
uploadLog() uploadLog()
showToast("专家已挂断") showToast("专家已挂断")
YDLavManager.instances.callEndStatusUpdate(channelId!!, 4, "对方离开频道") YDLavManager.instances.callEndStatusUpdate(channelId!!, 4, "对方离开频道")
if (totalDisposable != null) { if (totalDisposable != null) {
totalDisposable!!.dispose() totalDisposable!!.dispose()
...@@ -340,6 +346,7 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -340,6 +346,7 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
override fun onNetworkQuality(uid: Int, txQuality: Int, rxQuality: Int) { override fun onNetworkQuality(uid: Int, txQuality: Int, rxQuality: Int) {
super.onNetworkQuality(uid, txQuality, rxQuality) super.onNetworkQuality(uid, txQuality, rxQuality)
LogUtil.e("onNetworkQuality:-------uid=$uid,txQuality=$txQuality,rxQuality=$rxQuality")
var status = -1 var status = -1
var netStatus = when (uid) { var netStatus = when (uid) {
listenerUid!!.toInt() -> { listenerUid!!.toInt() -> {
...@@ -416,7 +423,10 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -416,7 +423,10 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
sensorManager = getSystemService(Context.SENSOR_SERVICE) as SensorManager? sensorManager = getSystemService(Context.SENSOR_SERVICE) as SensorManager?
localPowerManager = getSystemService(POWER_SERVICE) as PowerManager? localPowerManager = getSystemService(POWER_SERVICE) as PowerManager?
localWakeLock = localPowerManager!!.newWakeLock(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK, "yidianling") localWakeLock = localPowerManager!!.newWakeLock(
PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK,
"yidianling"
)
} }
private fun initIntentData() { private fun initIntentData() {
...@@ -432,9 +442,18 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -432,9 +442,18 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
listenerUid = intent.getStringExtra(IntentConstants.INTENT_LISTENER_UID) listenerUid = intent.getStringExtra(IntentConstants.INTENT_LISTENER_UID)
listenId = intent.getStringExtra(IntentConstants.INTENT_LISTEN_ID) listenId = intent.getStringExtra(IntentConstants.INTENT_LISTEN_ID)
commentUrl = intent.getStringExtra(IntentConstants.INTENT_COMMENT_URL) commentUrl = intent.getStringExtra(IntentConstants.INTENT_COMMENT_URL)
isShowAXB = intent.getBooleanExtra(IntentConstants.INTENT_ISSHOWAXB,true) isShowAXB = intent.getBooleanExtra(IntentConstants.INTENT_ISSHOWAXB, true)
val logBean = AgoraLogInfoBean(expertHeadUrl, expertName, channelId, remainTime, listenerUid, totalDuration, callId, listenId) val logBean = AgoraLogInfoBean(
expertHeadUrl,
expertName,
channelId,
remainTime,
listenerUid,
totalDuration,
callId,
listenId
)
val content = Gson().toJson(logBean) val content = Gson().toJson(logBean)
writeAgoraLog("主叫方发送的邀请通话消息内容:$content", isAppend = false) writeAgoraLog("主叫方发送的邀请通话消息内容:$content", isAppend = false)
...@@ -480,16 +499,17 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -480,16 +499,17 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
YDLImageCacheManager.showImage(this, expertHeadUrl, iv_head, option) YDLImageCacheManager.showImage(this, expertHeadUrl, iv_head, option)
} }
if(!isShowAXB){ if (!isShowAXB) {
tv_change_route.visibility=View.GONE tv_change_route.visibility = View.GONE
tv_change_time_counter.visibility=View.GONE tv_change_time_counter.visibility = View.GONE
} }
} }
private fun setClickEvent() { private fun setClickEvent() {
//切换线路 //切换线路
tv_change_route.setOnClickListener { tv_change_route.setOnClickListener {
showChooseDialog(1) } showChooseDialog(1)
}
//挂断 //挂断
iv_hang_up.setOnClickListener { iv_hang_up.setOnClickListener {
if (Utils.isFastClick()) { if (Utils.isFastClick()) {
...@@ -506,7 +526,11 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -506,7 +526,11 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
userCloseCalling() userCloseCalling()
} }
ActionCountUtils.count("shengwang_popup_layer_page|shengwang_popup_layer_refuse_click", YdlCommonRouterManager.getYdlCommonRoute().getUid().toString(), uid = YdlCommonRouterManager.getYdlCommonRoute().getUid().toString()) ActionCountUtils.count(
"shengwang_popup_layer_page|shengwang_popup_layer_refuse_click",
YdlCommonRouterManager.getYdlCommonRoute().getUid().toString(),
uid = YdlCommonRouterManager.getYdlCommonRoute().getUid().toString()
)
} }
//免提 //免提
...@@ -562,41 +586,58 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -562,41 +586,58 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
//初始化声网 //初始化声网
initializeAgoraEngine() initializeAgoraEngine()
//发起呼叫 //发起呼叫
var msgBean = AudioMessageBean(1, channelId!!, YdlCommonRouterManager.getYdlCommonRoute().getUid().toString(), YdlCommonRouterManager.getYdlCommonRoute().getUserInfo()!!.headUrl, YdlCommonRouterManager.getYdlCommonRoute().getUserInfo()!!.userName, remainTime!!.toInt(), relationId, callId, null, channelId) var msgBean = AudioMessageBean(
1,
channelId!!,
YdlCommonRouterManager.getYdlCommonRoute().getUid().toString(),
YdlCommonRouterManager.getYdlCommonRoute().getUserInfo()!!.headUrl,
YdlCommonRouterManager.getYdlCommonRoute().getUserInfo()!!.userName,
remainTime!!.toInt(),
relationId,
callId,
null,
channelId
)
sendDoctocrMsg = Gson().toJson(msgBean) sendDoctocrMsg = Gson().toJson(msgBean)
writeAgoraLog("主叫发送通话邀请") writeAgoraLog("主叫发送通话邀请")
rtcCall() rtcCall()
//开始60s等待倒计时 //开始60s等待倒计时
waitDisposable = Observable.interval(0, 100, TimeUnit.MILLISECONDS).subscribeOn(Schedulers.computation()).take(600).observeOn(AndroidSchedulers.mainThread()).subscribe({ waitDisposable =
tv_change_time_counter.text = "${60 - it / 10}s" Observable.interval(0, 100, TimeUnit.MILLISECONDS).subscribeOn(Schedulers.computation())
var result = it.toFloat() / 2.5f .take(600).observeOn(AndroidSchedulers.mainThread()).subscribe({
progress_view.setProgress(result) tv_change_time_counter.text = "${60 - it / 10}s"
if (result >= 100f && !iv_hang_up.isEnabled) { var result = it.toFloat() / 2.5f
//挂断按钮可点击 progress_view.setProgress(result)
iv_hang_up.isEnabled = true if (result >= 100f && !iv_hang_up.isEnabled) {
iv_hang_up.setImageResource(R.drawable.audioim_img_hang_up) //挂断按钮可点击
} iv_hang_up.isEnabled = true
}, { iv_hang_up.setImageResource(R.drawable.audioim_img_hang_up)
LogUtil.d(it.message)
}) {
waittingStatus()
if (!isConnectSuccess) {
//关闭音乐
stopPlaying()
writeAgoraLog("未接通挂断:60s等待倒计时结束挂断")
//提示切换传统线路
//发送消息通知专家用户已挂断
YDLavManager.instances.cancelCall(listenerUid!!, channelId!!, sendDoctocrMsg!!) { msg, code ->
writeAgoraLog("未接听时:主叫主动挂断失败,msg=$msg($code),再次挂断")
} }
//通话结束或挂断时,上传日志文件 }, {
uploadLog() LogUtil.d(it.message)
}) {
waittingStatus()
if (!isConnectSuccess) {
//关闭音乐
stopPlaying()
writeAgoraLog("未接通挂断:60s等待倒计时结束挂断")
//提示切换传统线路
//发送消息通知专家用户已挂断
YDLavManager.instances.cancelCall(
listenerUid!!,
channelId!!,
sendDoctocrMsg!!
) { msg, code ->
writeAgoraLog("未接听时:主叫主动挂断失败,msg=$msg($code),再次挂断")
}
//通话结束或挂断时,上传日志文件
uploadLog()
showChooseDialog(2) showChooseDialog(2)
}
} }
}
//双重保险:加入频道成功,通过服务端发推送给专家 //双重保险:加入频道成功,通过服务端发推送给专家
noticeServerPush(true) noticeServerPush(true)
...@@ -624,7 +665,12 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -624,7 +665,12 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
*/ */
fun joinChannel() { fun joinChannel() {
writeAgoraLog("对方接受了通话邀请,主叫开始加入频道:$channelId") writeAgoraLog("对方接受了通话邀请,主叫开始加入频道:$channelId")
voiceManage!!.getVoiceApi().joinChannel(token!!, channelId!!, "Extra Optional Data", YdlCommonRouterManager.getYdlCommonRoute().getUid()) voiceManage!!.getVoiceApi().joinChannel(
token!!,
channelId!!,
"Extra Optional Data",
YdlCommonRouterManager.getYdlCommonRoute().getUid()
)
} }
/** /**
...@@ -636,7 +682,11 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -636,7 +682,11 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
writeAgoraLog("未接听时:主叫主动挂断,取消呼叫") writeAgoraLog("未接听时:主叫主动挂断,取消呼叫")
LogUtil.e("未接听挂断") LogUtil.e("未接听挂断")
//发送消息通知专家用户已挂断 //发送消息通知专家用户已挂断
YDLavManager.instances.cancelCall(listenerUid!!, channelId!!, sendDoctocrMsg!!) { msg, code -> YDLavManager.instances.cancelCall(
listenerUid!!,
channelId!!,
sendDoctocrMsg!!
) { msg, code ->
writeAgoraLog("未接听时:主叫主动挂断失败,msg=$msg($code),再次挂断") writeAgoraLog("未接听时:主叫主动挂断失败,msg=$msg($code),再次挂断")
} }
//通话结束或挂断时,上传日志文件 //通话结束或挂断时,上传日志文件
...@@ -681,19 +731,20 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -681,19 +731,20 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
*/ */
private fun showChooseDialog(type: Int) { private fun showChooseDialog(type: Int) {
val dialog = AxbConfirmDialog(mContext, type, object : AxbConfirmDialog.OnClickEnsureListener { val dialog =
override fun onClickEnsure() { AxbConfirmDialog(mContext, type, object : AxbConfirmDialog.OnClickEnsureListener {
switchAXB() override fun onClickEnsure() {
} switchAXB()
}
override fun onClose() { override fun onClose() {
// 如果声网未连接成功,切换axb的弹框是自动弹出的,当关闭弹框的时候,执行用户挂断操作 // 如果声网未连接成功,切换axb的弹框是自动弹出的,当关闭弹框的时候,执行用户挂断操作
// 如果声网连接成功,点击右上角按钮弹出切换axb弹框,但是关闭时用户不执行挂断操作 // 如果声网连接成功,点击右上角按钮弹出切换axb弹框,但是关闭时用户不执行挂断操作
if (!isConnectSuccess) { if (!isConnectSuccess) {
userCloseCalling() userCloseCalling()
}
} }
} })
})
dialog.show() dialog.show()
} }
...@@ -708,7 +759,7 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -708,7 +759,7 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
} }
}) })
YDLavManager.instances.callEndStatusUpdate(channelId!!, 3, "接通中:主叫主动切换AXB") YDLavManager.instances.callEndStatusUpdate(channelId!!, 3, "接通中:主叫主动切换AXB")
} else { } else {
mPresenter.getAXBPhone(ConnectCommand(listenId!!, "1")) mPresenter.getAXBPhone(ConnectCommand(listenId!!, "1"))
...@@ -731,7 +782,11 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -731,7 +782,11 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
//未连接成功,切换axb时:需发送消息通知专家端用户已挂断 //未连接成功,切换axb时:需发送消息通知专家端用户已挂断
//发送消息通知专家用户已挂断 //发送消息通知专家用户已挂断
//发送消息通知专家用户已挂断 //发送消息通知专家用户已挂断
YDLavManager.instances.cancelCall(listenerUid!!, channelId!!, sendDoctocrMsg!!) { msg, code -> YDLavManager.instances.cancelCall(
listenerUid!!,
channelId!!,
sendDoctocrMsg!!
) { msg, code ->
writeAgoraLog("未接听时:主叫主动挂断失败,msg=$msg($code),再次挂断") writeAgoraLog("未接听时:主叫主动挂断失败,msg=$msg($code),再次挂断")
} }
leaveChannel() leaveChannel()
...@@ -763,9 +818,9 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -763,9 +818,9 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
tv_change_doctor.text = "对方暂无应答,正在为您切换线路重播" tv_change_doctor.text = "对方暂无应答,正在为您切换线路重播"
tv_change_doctor.visibility = View.VISIBLE tv_change_doctor.visibility = View.VISIBLE
} }
if(!isShowAXB){ if (!isShowAXB) {
tv_change_route.visibility=View.GONE tv_change_route.visibility = View.GONE
}else{ } else {
//切换线路按钮可见 //切换线路按钮可见
tv_change_route.isEnabled = true tv_change_route.isEnabled = true
tv_change_route.text = "切换至传统电话" tv_change_route.text = "切换至传统电话"
...@@ -857,32 +912,48 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -857,32 +912,48 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
tv_tips.visibility = View.GONE tv_tips.visibility = View.GONE
//剩余倾诉时长倒计时 //剩余倾诉时长倒计时
totalDisposable = Observable.interval(0, 1, TimeUnit.SECONDS).subscribeOn(Schedulers.computation()).take(remainTime!!.toLong() + 1).observeOn(AndroidSchedulers.mainThread()).subscribe({ totalDisposable =
localRemainTime = remainTime!!.toInt() - it.toInt() Observable.interval(0, 1, TimeUnit.SECONDS).subscribeOn(Schedulers.computation())
if (localRemainTime == 180) { .take(remainTime!!.toLong() + 1).observeOn(AndroidSchedulers.mainThread())
playNoticeMusic(3) .subscribe({
} localRemainTime = remainTime!!.toInt() - it.toInt()
if (localRemainTime == 60) { if (localRemainTime == 180) {
playNoticeMusic(1) playNoticeMusic(3)
} }
if (localRemainTime!! <= 60) { if (localRemainTime == 60) {
if (tv_change_route.isEnabled) { playNoticeMusic(1)
tv_change_route.isEnabled = false }
tv_change_route.setTextColor(ContextCompat.getColor(this, R.color.audioim_color_50ffffff)) if (localRemainTime!! <= 60) {
tv_change_route.setCompoundDrawablesWithIntrinsicBounds(null, null, ContextCompat.getDrawable(this, R.drawable.audioim_img_choose_arrow_unuse), null) if (tv_change_route.isEnabled) {
} tv_change_route.isEnabled = false
} tv_change_route.setTextColor(
tv_remain_time.text = DateUtils.formatTime(localRemainTime.toString()) ContextCompat.getColor(
}, { this,
LogUtil.d(it.message) R.color.audioim_color_50ffffff
}, { )
YDLavManager.instances.callEndStatusUpdate(channelId!!, 3, "倾诉时间已用完") )
//注意:自动挂断时,如果对方离开频道的回调已经触发,就不要再重复调用接口 tv_change_route.setCompoundDrawablesWithIntrinsicBounds(
showToast("通话已结束") null,
//通话结束或挂断时,上传日志文件 null,
uploadLog() ContextCompat.getDrawable(
updateExpertStatus(false, 1) this,
}) R.drawable.audioim_img_choose_arrow_unuse
),
null
)
}
}
tv_remain_time.text = DateUtils.formatTime(localRemainTime.toString())
}, {
LogUtil.d(it.message)
}, {
YDLavManager.instances.callEndStatusUpdate(channelId!!, 3, "倾诉时间已用完")
//注意:自动挂断时,如果对方离开频道的回调已经触发,就不要再重复调用接口
showToast("通话已结束")
//通话结束或挂断时,上传日志文件
uploadLog()
updateExpertStatus(false, 1)
})
} }
/** /**
...@@ -912,7 +983,18 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -912,7 +983,18 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
* @param isCall true 拨打 false 取消拨打 * @param isCall true 拨打 false 取消拨打
*/ */
private fun noticeServerPush(isCall: Boolean) { private fun noticeServerPush(isCall: Boolean) {
var msgBean = AudioMessageBean(1, channelId!!, YdlCommonRouterManager.getYdlCommonRoute().getUid().toString(), YdlCommonRouterManager.getYdlCommonRoute().getUserInfo()!!.headUrl, YdlCommonRouterManager.getYdlCommonRoute().getUserInfo()!!.userName, remainTime!!.toInt(), relationId, callId, null, channelId) var msgBean = AudioMessageBean(
1,
channelId!!,
YdlCommonRouterManager.getYdlCommonRoute().getUid().toString(),
YdlCommonRouterManager.getYdlCommonRoute().getUserInfo()!!.headUrl,
YdlCommonRouterManager.getYdlCommonRoute().getUserInfo()!!.userName,
remainTime!!.toInt(),
relationId,
callId,
null,
channelId
)
var cmd = NoticePushCommand() var cmd = NoticePushCommand()
cmd.data = msgBean cmd.data = msgBean
cmd.pushId = listenerUid cmd.pushId = listenerUid
...@@ -941,10 +1023,18 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -941,10 +1023,18 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
sensorManager!!.registerListener(this, sensorManager!!.getDefaultSensor(Sensor.TYPE_PROXIMITY), SensorManager.SENSOR_DELAY_NORMAL) sensorManager!!.registerListener(
this,
sensorManager!!.getDefaultSensor(Sensor.TYPE_PROXIMITY),
ActionCountUtils.count("shengwang_popup_layer_page|shengwang_popup_layer_page_visit", "", uid = YdlCommonRouterManager.getYdlCommonRoute().getUid().toString()) SensorManager.SENSOR_DELAY_NORMAL
)
ActionCountUtils.count(
"shengwang_popup_layer_page|shengwang_popup_layer_page_visit",
"",
uid = YdlCommonRouterManager.getYdlCommonRoute().getUid().toString()
)
} }
override fun onAccuracyChanged(sensor: Sensor?, accuracy: Int) { override fun onAccuracyChanged(sensor: Sensor?, accuracy: Int) {
...@@ -989,10 +1079,20 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -989,10 +1079,20 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
} else { } else {
tv_nte_status.text = msg tv_nte_status.text = msg
if (status == 0) { if (status == 0) {
tv_nte_status.setCompoundDrawablesWithIntrinsicBounds(ContextCompat.getDrawable(this, R.drawable.av_audio_wifi_normal), null, null, null) tv_nte_status.setCompoundDrawablesWithIntrinsicBounds(
ContextCompat.getDrawable(
this,
R.drawable.av_audio_wifi_normal
), null, null, null
)
} }
if (status == 1) { if (status == 1) {
tv_nte_status.setCompoundDrawablesWithIntrinsicBounds(ContextCompat.getDrawable(this, R.drawable.av_audio_wifi_better), null, null, null) tv_nte_status.setCompoundDrawablesWithIntrinsicBounds(
ContextCompat.getDrawable(
this,
R.drawable.av_audio_wifi_better
), null, null, null
)
} }
if (status == -1) { if (status == -1) {
tv_nte_status.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null) tv_nte_status.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null)
...@@ -1034,11 +1134,18 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -1034,11 +1134,18 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
* 上传错误日志 * 上传错误日志
* zhu 洪平要的,判别是移动端主动调的还是声网返的 * zhu 洪平要的,判别是移动端主动调的还是声网返的
*/ */
private fun uploadException(message: String, zhu: String = "", eventType: String = "99", callback: YDLavManager.UploadExceptionCallback?) { private fun uploadException(
message: String,
zhu: String = "",
eventType: String = "99",
callback: YDLavManager.UploadExceptionCallback?
) {
var time: String = (System.currentTimeMillis() / 1000).toString() var time: String = (System.currentTimeMillis() / 1000).toString()
var uid: String = ModularServiceManager.provide(IUserService::class.java).getUserInfo()?.uid!! var uid: String =
ModularServiceManager.provide(IUserService::class.java).getUserInfo()?.uid!!
var payLoad = PayLoad(channelId ?: "0", time, uid, "1", "999", message) var payLoad = PayLoad(channelId ?: "0", time, uid, "1", "999", message)
var connectException = ConnectExceptionCommand(time + zhu, "2", eventType, payLoad, callStatus) var connectException =
ConnectExceptionCommand(time + zhu, "2", eventType, payLoad, callStatus)
YDLavManager.instances.uploadException(connectException, callback) YDLavManager.instances.uploadException(connectException, callback)
} }
......
...@@ -154,7 +154,11 @@ class YDLavManager { ...@@ -154,7 +154,11 @@ class YDLavManager {
RtmStatusCode.LocalInvitationError.LOCAL_INVITATION_ERR_INVITATION_EXPIRE -> { //呼叫邀请过期。被叫 ACK 响应呼叫邀请后 60 秒呼叫邀请未被取消、接受、拒绝,则呼叫邀请过期。 RtmStatusCode.LocalInvitationError.LOCAL_INVITATION_ERR_INVITATION_EXPIRE -> { //呼叫邀请过期。被叫 ACK 响应呼叫邀请后 60 秒呼叫邀请未被取消、接受、拒绝,则呼叫邀请过期。
if (act is AudioHomeActivity) { if (act is AudioHomeActivity) {
act.runOnUiThread { act.runOnUiThread {
sendCustomNotification(response?.calleeId!!, response?.ChannelId!!, "5") sendCustomNotification(
response?.calleeId!!,
response?.ChannelId!!,
"5"
)
callEndStatusUpdate(response.ChannelId!!, 2, "被叫超时未接听") callEndStatusUpdate(response.ChannelId!!, 2, "被叫超时未接听")
act.writeAgoraLog("呼叫失败:${errorCode}") act.writeAgoraLog("呼叫失败:${errorCode}")
act.uploadExceptionStatus("对方未接听", 3) act.uploadExceptionStatus("对方未接听", 3)
...@@ -224,8 +228,12 @@ class YDLavManager { ...@@ -224,8 +228,12 @@ class YDLavManager {
}) })
AudioImIn.registerObserveCustomNotification(object : AudioImIn.registerObserveCustomNotification(object :
IMRegisterObserverCustomNotificationCallBack { IMRegisterObserverCustomNotificationCallBack {
override fun onObserverCustomNotification(fromUid: String, toUid: String, content: String) { override fun onObserverCustomNotification(
fromUid: String,
toUid: String,
content: String
) {
LogUtil.e("[agora]收到云信的通知消息:$content") LogUtil.e("[agora]收到云信的通知消息:$content")
val agoraInvitationBean = Gson().fromJson(content, AgoraInvitationBean::class.java) val agoraInvitationBean = Gson().fromJson(content, AgoraInvitationBean::class.java)
...@@ -284,16 +292,24 @@ class YDLavManager { ...@@ -284,16 +292,24 @@ class YDLavManager {
sendCustomNotification(toUid, data, "4") sendCustomNotification(toUid, data, "4")
} }
fun cancelCall(listenerUid: String, channelId: String, data: String, event: (msg: String?, code: Int) -> Unit) { fun cancelCall(
YDLRTMClient.instances.cancelCall(listenerUid, channelId, object : CancelCallStatusListener { listenerUid: String,
override fun onFailure(errorMsg: String?, errorCode: Int) { channelId: String,
event(errorMsg, errorCode) data: String,
YDLRTMClient.instances.cancelCall(listenerUid, channelId, null) event: (msg: String?, code: Int) -> Unit
} ) {
YDLRTMClient.instances.cancelCall(
listenerUid,
channelId,
object : CancelCallStatusListener {
override fun onFailure(errorMsg: String?, errorCode: Int) {
event(errorMsg, errorCode)
YDLRTMClient.instances.cancelCall(listenerUid, channelId, null)
}
override fun onSuccess() { override fun onSuccess() {
} }
}) })
callEndStatusUpdate(channelId, 1, "主叫取消呼叫") callEndStatusUpdate(channelId, 1, "主叫取消呼叫")
sendCustomNotification(listenerUid, data, "3") sendCustomNotification(listenerUid, data, "3")
...@@ -304,16 +320,16 @@ class YDLavManager { ...@@ -304,16 +320,16 @@ class YDLavManager {
infoBean.data = data infoBean.data = data
infoBean.callType = callType infoBean.callType = callType
AudioImIn.sendCustomNotification(toUid, Gson().toJson(infoBean), AudioImIn.sendCustomNotification(toUid, Gson().toJson(infoBean),
object : IMSendCustomNotificationResultCallBack { object : IMSendCustomNotificationResultCallBack {
override fun onException(throwable: Throwable) { override fun onException(throwable: Throwable) {
} }
override fun onFailed(code: Int) { override fun onFailed(code: Int) {
} }
override fun onSuccess() { override fun onSuccess() {
} }
}) })
} }
fun login(userId: String?) { fun login(userId: String?) {
...@@ -331,10 +347,12 @@ class YDLavManager { ...@@ -331,10 +347,12 @@ class YDLavManager {
//登录实时消息 //登录实时消息
//获取token //获取token
AudioApiRequestUtil.getAgoraToken().subscribeOn(Schedulers.io()) AudioApiRequestUtil.getAgoraToken().subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()).subscribe({ .observeOn(AndroidSchedulers.mainThread()).subscribe({
if ("200".equals(it.code)) { if ("200".equals(it.code)) {
LogUtil.e("[agora]登录av的login-uid:$userId") LogUtil.e("[agora]登录av的login-uid:$userId")
YDLRTMClient.instances.login(LoginParam(userId, it.data.token), object : LoginCallback { YDLRTMClient.instances.login(
LoginParam(userId, it.data.token),
object : LoginCallback {
override fun onSuccess() { override fun onSuccess() {
//登陆成功,发起呼叫 //登陆成功,发起呼叫
LogUtil.e("[agora]实时消息登录成功") LogUtil.e("[agora]实时消息登录成功")
...@@ -346,13 +364,14 @@ class YDLavManager { ...@@ -346,13 +364,14 @@ class YDLavManager {
event(false, msg) event(false, msg)
} }
}) })
} else { } else {
LogUtil.e("声网token获取失败uid:" + userId + " error:" + it.msg) LogUtil.e("声网token获取失败uid:" + userId + " error:" + it.msg)
LogHelper.getInstance().writeLogSync("声网token获取失败uid:" + userId + " error:" + it.msg) LogHelper.getInstance()
} .writeLogSync("声网token获取失败uid:" + userId + " error:" + it.msg)
}, { }
LogUtil.e("声网token获取异常uid:" + userId + " error:" + it.message) }, {
}) LogUtil.e("声网token获取异常uid:" + userId + " error:" + it.message)
})
} }
/** /**
...@@ -363,17 +382,19 @@ class YDLavManager { ...@@ -363,17 +382,19 @@ class YDLavManager {
if (!TextUtils.isEmpty(content)) { if (!TextUtils.isEmpty(content)) {
//如果已经接听了用户电话 再有电话进来 是不能接听的 //如果已经接听了用户电话 再有电话进来 是不能接听的
if (!activityIsExists(ConsultantAudioHomeActivity::class.java) && !activityIsExists( if (!activityIsExists(ConsultantAudioHomeActivity::class.java) && !activityIsExists(
AudioHomeActivity::class.java)) { AudioHomeActivity::class.java
)
) {
//延时启动通话界面,防止刚打开就被main遮挡 //延时启动通话界面,防止刚打开就被main遮挡
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]启动通话界面")
//邀请加入频道消息,跳转通话界面 //邀请加入频道消息,跳转通话界面
ARouter.getInstance().build("/av/ConsultantAudioHomeActivity") ARouter.getInstance().build("/av/ConsultantAudioHomeActivity")
.withString("param", content).navigation() .withString("param", content).navigation()
AudioLogUtils.writeAgoraLog("收到主叫方通话邀请($from)", FILE_NAME, false) AudioLogUtils.writeAgoraLog("收到主叫方通话邀请($from)", FILE_NAME, false)
} }
} else { } else {
LogUtil.d("[agora]收到声网邀请,但界面实例已存在") LogUtil.d("[agora]收到声网邀请,但界面实例已存在")
} }
...@@ -426,14 +447,16 @@ class YDLavManager { ...@@ -426,14 +447,16 @@ class YDLavManager {
* 声网出现异常,上传错误日志 connectException * 声网出现异常,上传错误日志 connectException
*/ */
@SuppressLint("CheckResult") @SuppressLint("CheckResult")
fun uploadException(connectException: ConnectExceptionCommand, fun uploadException(
callback: UploadExceptionCallback?) { connectException: ConnectExceptionCommand,
callback: UploadExceptionCallback?
) {
AudioApiRequestUtil.connectException(connectException).subscribeOn(Schedulers.io()) AudioApiRequestUtil.connectException(connectException).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()).subscribe({ .observeOn(AndroidSchedulers.mainThread()).subscribe({
callback?.onSuccess() callback?.onSuccess()
}, { }, {
LogUtil.e("agora", "声网上传异常与错误日志接口调用失败:" + it.message) LogUtil.e("agora", "声网上传异常与错误日志接口调用失败:" + it.message)
}) })
} }
/** /**
...@@ -447,10 +470,13 @@ class YDLavManager { ...@@ -447,10 +470,13 @@ class YDLavManager {
@SuppressLint("CheckResult") @SuppressLint("CheckResult")
fun callEndStatusUpdate(channelId: String, endStatus: Int, msg: String) { fun callEndStatusUpdate(channelId: String, endStatus: Int, msg: String) {
AudioApiRequestUtil.callEndStatusUpdate(channelId, endStatus, msg) AudioApiRequestUtil.callEndStatusUpdate(channelId, endStatus, msg)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()).subscribe({ .observeOn(AndroidSchedulers.mainThread())
}, { .subscribe({
}) LogUtil.d("callEndStatusUpdate success")
}, {
LogUtil.d("callEndStatusUpdate error: ${it.message}")
})
} }
/** /**
......
...@@ -69,7 +69,8 @@ interface AudioNetAPi { ...@@ -69,7 +69,8 @@ interface AudioNetAPi {
fun listenToken(@FieldMap map: Map<String, String>): Observable<BaseResponse<ListenTokenBean>> fun listenToken(@FieldMap map: Map<String, String>): Observable<BaseResponse<ListenTokenBean>>
@Headers( YDL_DOMAIN + YDL_DOMAIN_JAVA)
@GET("message/call-end/agora") @GET("message/call-end/agora")
fun callEndStatusUpdate(channelId:String,endStatus:Int,msg:String): Observable<BaseResponse<Any>> fun callEndStatusUpdate(@Query("channelId") channelId:String,@Query("endStatus") endStatus:Int,@Query("msg") msg:String): Observable<BaseResponse<Any>>
} }
\ No newline at end of file
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