Commit ebe6578a by 严久程

接口参数

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