Commit b3c3fac4 by 严久程

咨询接入声网逻辑

parent c791b7b6
...@@ -42,7 +42,7 @@ ext { ...@@ -42,7 +42,7 @@ ext {
ydlPublishVersion = [ ydlPublishVersion = [
// -------------- 业务模块 -------------- // -------------- 业务模块 --------------
//第三步 若干 //第三步 若干
"m-confide" : "0.0.48.7.12", "m-confide" : "0.0.48.7.14",
"m-consultant" : "0.0.57.4", "m-consultant" : "0.0.57.4",
"m-fm" : "0.0.29.3", "m-fm" : "0.0.29.3",
"m-user" : "0.0.60.1", "m-user" : "0.0.60.1",
...@@ -75,7 +75,7 @@ ext { ...@@ -75,7 +75,7 @@ ext {
"ydl-webview" : "0.0.38.24", "ydl-webview" : "0.0.38.24",
"ydl-media" : "0.0.20", "ydl-media" : "0.0.20",
"ydl-pay" : "0.0.17", "ydl-pay" : "0.0.17",
"m-audioim" : "0.0.48.2.6", "m-audioim" : "0.0.48.3.4",
"ydl-flutter-base": "0.0.10.9", "ydl-flutter-base": "0.0.10.9",
//以下 几乎不会动 //以下 几乎不会动
...@@ -121,7 +121,7 @@ ext { ...@@ -121,7 +121,7 @@ ext {
"ydl-webview" : "0.0.38.24", "ydl-webview" : "0.0.38.24",
"ydl-media" : "0.0.20", "ydl-media" : "0.0.20",
"ydl-pay" : "0.0.17", "ydl-pay" : "0.0.17",
"m-audioim" : "0.0.48.3.2", "m-audioim" : "0.0.48.3.4",
"ydl-flutter-base": "0.0.10.9", "ydl-flutter-base": "0.0.10.9",
//以下 几乎不会动 //以下 几乎不会动
......
...@@ -35,15 +35,11 @@ import com.ydl.audioim.presenter.AudioHomePresenterImpl ...@@ -35,15 +35,11 @@ import com.ydl.audioim.presenter.AudioHomePresenterImpl
import com.ydl.audioim.utils.AudioLogUtils import com.ydl.audioim.utils.AudioLogUtils
import com.ydl.audioim.utils.DateUtils import com.ydl.audioim.utils.DateUtils
import com.ydl.audioim.widget.AxbConfirmDialog import com.ydl.audioim.widget.AxbConfirmDialog
import com.ydl.burypointlib.ToastUtil
import com.ydl.webview.H5Params import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity import com.ydl.webview.NewH5Activity
import com.ydl.webview.RefreshWebEvent import com.ydl.webview.RefreshWebEvent
import com.ydl.ydl_av.chat.bean.AudioMessageBean import com.ydl.ydl_av.chat.bean.AudioMessageBean
import com.ydl.ydl_av.messge_service.YDLRTMClient import com.ydl.ydl_av.messge_service.YDLRTMClient
import com.ydl.ydl_av.messge_service.callback.CallListener
import com.ydl.ydl_av.messge_service.response.CallLocalResponse
import com.ydl.ydl_av.messge_service.response.CallRemoteResponse
import com.ydl.ydl_av.voice.listener.IYDLVoiceEventHandler import com.ydl.ydl_av.voice.listener.IYDLVoiceEventHandler
import com.ydl.ydl_av.voice.manager.YDLVoiceManager import com.ydl.ydl_av.voice.manager.YDLVoiceManager
import com.ydl.ydl_image.config.SimpleImageOpConfiger import com.ydl.ydl_image.config.SimpleImageOpConfiger
...@@ -60,7 +56,6 @@ import com.ydl.ydlcommon.utils.remind.ToastHelper ...@@ -60,7 +56,6 @@ import com.ydl.ydlcommon.utils.remind.ToastHelper
import com.yidianling.user.api.service.IUserService import com.yidianling.user.api.service.IUserService
import de.greenrobot.event.EventBus import de.greenrobot.event.EventBus
import io.agora.rtc.IRtcEngineEventHandler import io.agora.rtc.IRtcEngineEventHandler
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.disposables.Disposable import io.reactivex.disposables.Disposable
...@@ -273,7 +268,7 @@ class AudioHomeActivity : ...@@ -273,7 +268,7 @@ class AudioHomeActivity :
LogUtil.e("[agora]$uid 用户声网重新加入频道成功:channel=$channel") LogUtil.e("[agora]$uid 用户声网重新加入频道成功:channel=$channel")
runOnUiThread { runOnUiThread {
//自己加入频道成功 //自己加入频道成功
if(!isConnectSuccess){ if (!isConnectSuccess) {
connectSuccess() connectSuccess()
} }
} }
...@@ -472,7 +467,11 @@ class AudioHomeActivity : ...@@ -472,7 +467,11 @@ class AudioHomeActivity :
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()
)
} }
//免提 //免提
...@@ -630,7 +629,8 @@ class AudioHomeActivity : ...@@ -630,7 +629,8 @@ class AudioHomeActivity :
.subscribeOn(Schedulers.computation()) .subscribeOn(Schedulers.computation())
.take(603) .take(603)
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe({ var result = it.toFloat() / 2.5f .subscribe({
var result = it.toFloat() / 2.5f
progress_view.setProgress(result) progress_view.setProgress(result)
if (result >= 100f && !iv_hang_up.isEnabled) { if (result >= 100f && !iv_hang_up.isEnabled) {
//挂断按钮可点击 //挂断按钮可点击
...@@ -658,7 +658,7 @@ class AudioHomeActivity : ...@@ -658,7 +658,7 @@ class AudioHomeActivity :
noticeServerPush(true) noticeServerPush(true)
} }
fun rtcCall(){ fun rtcCall() {
YDLRTMClient.instances.call(listenerUid!!, channelId, sendDoctocrMsg) YDLRTMClient.instances.call(listenerUid!!, channelId, sendDoctocrMsg)
} }
...@@ -1040,7 +1040,7 @@ class AudioHomeActivity : ...@@ -1040,7 +1040,7 @@ class AudioHomeActivity :
/** /**
* 声网离开频道 * 声网离开频道
*/ */
fun leaveChannel() { fun leaveChannel() {
if (!isLeavelChannel) { if (!isLeavelChannel) {
isLeavelChannel = true isLeavelChannel = true
//刷新h5页面 //刷新h5页面
...@@ -1060,7 +1060,11 @@ class AudioHomeActivity : ...@@ -1060,7 +1060,11 @@ class AudioHomeActivity :
) )
ActionCountUtils.count("shengwang_popup_layer_page|shengwang_popup_layer_page_visit", "", uid = YdlCommonRouterManager.getYdlCommonRoute().getUid().toString()) 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) {
...@@ -1120,7 +1124,7 @@ class AudioHomeActivity : ...@@ -1120,7 +1124,7 @@ class AudioHomeActivity :
} }
fun uploadLog() { fun uploadLog() {
if (!hasUpLoadLog) { if (!hasUpLoadLog) {
hasUpLoadLog = true hasUpLoadLog = true
LogHelper.getInstance().uploadLog(false) LogHelper.getInstance().uploadLog(false)
......
...@@ -4,9 +4,12 @@ import com.google.gson.Gson ...@@ -4,9 +4,12 @@ import com.google.gson.Gson
import com.ydl.audioim.bean.AgoraTokenResponse import com.ydl.audioim.bean.AgoraTokenResponse
import com.ydl.audioim.bean.ConnectBean import com.ydl.audioim.bean.ConnectBean
import com.ydl.audioim.http.command.* import com.ydl.audioim.http.command.*
import com.ydl.consultantim.bean.ListenTokenBean
import com.ydl.consultantim.command.ListenTokenCmd
import com.ydl.ydlcommon.data.http.BaseAPIResponse import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.ydl.ydlcommon.data.http.BaseResponse import com.ydl.ydlcommon.data.http.BaseResponse
import com.ydl.ydlcommon.data.http.RxUtils import com.ydl.ydlcommon.data.http.RxUtils
import com.ydl.ydlcommon.utils.NetworkParamsUtils
import com.ydl.ydlnet.YDLHttpUtils import com.ydl.ydlnet.YDLHttpUtils
import io.reactivex.Observable import io.reactivex.Observable
import okhttp3.MediaType import okhttp3.MediaType
...@@ -85,5 +88,12 @@ class AudioApiRequestUtil { ...@@ -85,5 +88,12 @@ class AudioApiRequestUtil {
fun getAgoraToken(): Observable<BaseAPIResponse<AgoraTokenResponse>>{ fun getAgoraToken(): Observable<BaseAPIResponse<AgoraTokenResponse>>{
return YDLHttpUtils.obtainApi(AudioNetAPi::class.java).getAgoraToken() return YDLHttpUtils.obtainApi(AudioNetAPi::class.java).getAgoraToken()
} }
/**
* 获取声网登录token
*/
fun listenToken(cmd: ListenTokenCmd): Observable<BaseResponse<ListenTokenBean>>{
return YDLHttpUtils.obtainApi(AudioNetAPi::class.java).listenToken(NetworkParamsUtils.getMaps(cmd))
}
} }
} }
\ No newline at end of file
...@@ -68,4 +68,5 @@ interface AudioNetAPi { ...@@ -68,4 +68,5 @@ interface AudioNetAPi {
@POST("listen/token") @POST("listen/token")
fun listenToken(@FieldMap map: Map<String, String>): Observable<BaseResponse<ListenTokenBean>> fun listenToken(@FieldMap map: Map<String, String>): Observable<BaseResponse<ListenTokenBean>>
} }
\ No newline at end of file
...@@ -95,6 +95,7 @@ class ConsultantAudioHomeActivity : ...@@ -95,6 +95,7 @@ class ConsultantAudioHomeActivity :
* 本次倾述倒计时 * 本次倾述倒计时
*/ */
private var totalDisposable: Disposable? = null private var totalDisposable: Disposable? = null
private var connectingStatusDisposable: Disposable? = null
//频道管理器 //频道管理器
// private var channelManager: ChannelManager? = null // private var channelManager: ChannelManager? = null
...@@ -102,6 +103,11 @@ class ConsultantAudioHomeActivity : ...@@ -102,6 +103,11 @@ class ConsultantAudioHomeActivity :
//频道token //频道token
private var channelToken: String? = null private var channelToken: String? = null
private var hasUpLoadLog = false private var hasUpLoadLog = false
/**
* 是否连接成功
*/
private var isConnectSuccess: Boolean = false
/** /**
* 事件回调 (SDK 通过指定的事件通知应用程序 SDK 的运行事件,如: 加入或离开频道,新用户加入频道等) * 事件回调 (SDK 通过指定的事件通知应用程序 SDK 的运行事件,如: 加入或离开频道,新用户加入频道等)
*/ */
...@@ -126,6 +132,11 @@ class ConsultantAudioHomeActivity : ...@@ -126,6 +132,11 @@ class ConsultantAudioHomeActivity :
runOnUiThread { runOnUiThread {
tv_toast.visibility = View.VISIBLE tv_toast.visibility = View.VISIBLE
tv_toast.text = "连接中..." tv_toast.text = "连接中..."
voiceManage!!.getVoiceApi().setEnableSpeakerphone(false)
//5s倒计时,5s后还是连接中,则直接关闭页面
connectingStatusWaitingTimeCount()
} }
} }
...@@ -134,6 +145,7 @@ class ConsultantAudioHomeActivity : ...@@ -134,6 +145,7 @@ class ConsultantAudioHomeActivity :
LogUtil.e("[agora]远端用户加入频道回调") LogUtil.e("[agora]远端用户加入频道回调")
//另一方加入频道成功 //另一方加入频道成功
runOnUiThread { runOnUiThread {
isConnectSuccess = true
//通话开始,刷新ui开始倒计时 //通话开始,刷新ui开始倒计时
updateStartUi() updateStartUi()
status = STATUS_ANSWERED status = STATUS_ANSWERED
...@@ -204,6 +216,19 @@ class ConsultantAudioHomeActivity : ...@@ -204,6 +216,19 @@ 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 重新加入频道回调")
runOnUiThread {
if (!isConnectSuccess) {
tv_toast.visibility = View.VISIBLE
tv_toast.text = "连接中..."
voiceManage!!.getVoiceApi().setEnableSpeakerphone(false)
//5s倒计时,5s后还是连接中,则直接关闭页面
connectingStatusWaitingTimeCount()
}
}
} }
/** /**
...@@ -336,6 +361,8 @@ class ConsultantAudioHomeActivity : ...@@ -336,6 +361,8 @@ class ConsultantAudioHomeActivity :
if (!TextUtils.isEmpty(json)) { if (!TextUtils.isEmpty(json)) {
writeAgoraLog(json) writeAgoraLog(json)
mAudioMessageBean = Gson().fromJson(json, AudioMessageBean::class.java) mAudioMessageBean = Gson().fromJson(json, AudioMessageBean::class.java)
YDLavManager.instances.login(ModularServiceManager.provide(IUserService::class.java).getUserInfo()?.uid)
} }
} else { } else {
close(RESULT_NOT_ANSWERED_CODE, "通话异常") close(RESULT_NOT_ANSWERED_CODE, "通话异常")
...@@ -482,6 +509,18 @@ class ConsultantAudioHomeActivity : ...@@ -482,6 +509,18 @@ class ConsultantAudioHomeActivity :
} }
} }
/**
* 更新ui
*/
private fun updateUI() {
tv_toast.visibility = View.VISIBLE
tv_toast.text = "正在建立连接..."
rl_call.visibility = View.GONE
rl_hands_free.visibility = View.VISIBLE
}
//申请音频权限 //申请音频权限
@SuppressLint("CheckResult") @SuppressLint("CheckResult")
private fun requestPermission() { private fun requestPermission() {
...@@ -524,20 +563,10 @@ class ConsultantAudioHomeActivity : ...@@ -524,20 +563,10 @@ class ConsultantAudioHomeActivity :
*/ */
voiceManage = YDLVoiceManager(this, BuildConfig.AGORA_APPID, mRtcEventHandler) voiceManage = YDLVoiceManager(this, BuildConfig.AGORA_APPID, mRtcEventHandler)
voiceManage!!.init() voiceManage!!.init()
//默认听筒模式
voiceManage!!.getVoiceApi().setEnableSpeakerphone(false)
} }
/** /**
* 更新ui
*/
private fun updateUI() {
rl_call.visibility = View.GONE
rl_hands_free.visibility = View.VISIBLE
}
/**
* 加入频道 * 加入频道
*/ */
private fun joinChannel() { private fun joinChannel() {
...@@ -568,13 +597,16 @@ class ConsultantAudioHomeActivity : ...@@ -568,13 +597,16 @@ class ConsultantAudioHomeActivity :
rl_remain_time.visibility = View.VISIBLE rl_remain_time.visibility = View.VISIBLE
totalDisposable = Observable.interval(0, 1, TimeUnit.SECONDS) totalDisposable = Observable.interval(0, 1, TimeUnit.SECONDS)
.subscribeOn(Schedulers.computation()) .subscribeOn(Schedulers.computation())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe({ .subscribe({
tv_remain_time.text = DateUtils.formatTime(it.toString()) tv_remain_time.text = DateUtils.formatTime(it.toString())
}, {}) }, {
//通话结束或挂断时,上传日志文件
uploadLog()
close(RESULT_NOT_ANSWERED_CODE, "对方异常")
})
} }
/** /**
...@@ -797,6 +829,25 @@ class ConsultantAudioHomeActivity : ...@@ -797,6 +829,25 @@ class ConsultantAudioHomeActivity :
} }
/** /**
*连接中状态倒计时:5s后如果还是处于连接中,则直接退出当前页面
*/
private fun connectingStatusWaitingTimeCount() {
if (connectingStatusDisposable == null) {
connectingStatusDisposable = Observable.interval(0, 1, TimeUnit.SECONDS)
.subscribeOn(Schedulers.computation())
.take(6)
.observeOn(AndroidSchedulers.mainThread())
.subscribe({}, {}, {
if (!isConnectSuccess) {
ToastUtil.toastShort(this, "用户已挂断")
close(RESULT_NOT_ANSWERED_CODE, "")
}
})
}
}
/**
* 离开频道 * 离开频道
*/ */
private fun leaveChannel() { private fun leaveChannel() {
...@@ -804,6 +855,11 @@ class ConsultantAudioHomeActivity : ...@@ -804,6 +855,11 @@ class ConsultantAudioHomeActivity :
if (totalDisposable != null) { if (totalDisposable != null) {
totalDisposable!!.dispose() totalDisposable!!.dispose()
} }
if (connectingStatusDisposable != null) {
connectingStatusDisposable!!.dispose()
}
if (null != voiceManage && null != voiceManage!!.getVoiceApi()) { if (null != voiceManage && null != voiceManage!!.getVoiceApi()) {
voiceManage!!.getVoiceApi().leaveChannel() voiceManage!!.getVoiceApi().leaveChannel()
voiceManage!!.getVoiceApi().destroy() voiceManage!!.getVoiceApi().destroy()
...@@ -871,6 +927,7 @@ class ConsultantAudioHomeActivity : ...@@ -871,6 +927,7 @@ class ConsultantAudioHomeActivity :
LogUtil.e("http-------------onDestory") LogUtil.e("http-------------onDestory")
leaveChannel() leaveChannel()
voiceDestory() voiceDestory()
isConnectSuccess = false
status = STATUS_NOT_ANSWERED status = STATUS_NOT_ANSWERED
hasUpLoadLog = false hasUpLoadLog = false
EventBus.getDefault().unregister(this) EventBus.getDefault().unregister(this)
......
package com.ydl.consultantim.presenter package com.ydl.consultantim.presenter
import android.annotation.SuppressLint
import com.ydl.audioim.http.AudioApiRequestUtil
import com.ydl.consultantim.command.ListenTokenCmd import com.ydl.consultantim.command.ListenTokenCmd
import com.ydl.consultantim.contract.IConsultantAudioHomeActivityContract import com.ydl.consultantim.contract.IConsultantAudioHomeActivityContract
import com.ydl.consultantim.model.ConsultantAudioHomeModelImpl import com.ydl.consultantim.model.ConsultantAudioHomeModelImpl
...@@ -7,6 +9,8 @@ import com.ydl.ydl_av.chat.bean.AudioMessageBean ...@@ -7,6 +9,8 @@ import com.ydl.ydl_av.chat.bean.AudioMessageBean
import com.ydl.ydlcommon.modular.ModularServiceManager import com.ydl.ydlcommon.modular.ModularServiceManager
import com.ydl.ydlcommon.mvp.base.BasePresenter import com.ydl.ydlcommon.mvp.base.BasePresenter
import com.yidianling.user.api.service.IUserService import com.yidianling.user.api.service.IUserService
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
/** /**
* @author jiucheng * @author jiucheng
...@@ -30,6 +34,7 @@ class ConsultantAudioHomePresenterImpl : ...@@ -30,6 +34,7 @@ class ConsultantAudioHomePresenterImpl :
// }) // })
} }
@SuppressLint("CheckResult")
override fun getChannelToken(msgBean: AudioMessageBean?, needJoinChannel: Boolean) { override fun getChannelToken(msgBean: AudioMessageBean?, needJoinChannel: Boolean) {
if (ModularServiceManager.provide(IUserService::class.java).isLogin()) { if (ModularServiceManager.provide(IUserService::class.java).isLogin()) {
if (null != ModularServiceManager.provide(IUserService::class.java).getUserInfo()) { if (null != ModularServiceManager.provide(IUserService::class.java).getUserInfo()) {
...@@ -40,15 +45,13 @@ class ConsultantAudioHomePresenterImpl : ...@@ -40,15 +45,13 @@ class ConsultantAudioHomePresenterImpl :
tokenParam.account = acount.toString() tokenParam.account = acount.toString()
tokenParam.uid = acount.toString() tokenParam.uid = acount.toString()
tokenParam.channelId = msgBean?.channelId tokenParam.channelId = msgBean?.channelId
//todo AudioApiRequestUtil.listenToken(tokenParam)
// RetrofitUtils.listenToken(tokenParam) .subscribeOn(Schedulers.io())
// .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread())
// .observeOn(AndroidSchedulers.mainThread()) .subscribe({
// .subscribe({ mView.channelTokenResponse(it.data.token, needJoinChannel)
// view.channelTokenResponse(it.data.token, needJoinChannel) }, {
// }, { })
// RetrofitUtils.handleError(it)
// })
} }
} }
} }
......
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