|
@@ -253,10 +253,8 @@ class WdKeepAliveService : AbsWorkService() {
|
|
|
|
|
|
val tcpModel = messageEvent.getMessage() as TcpModel
|
|
|
if (tcpModel.type == TcpType.VOICE) {
|
|
|
-// var gson = GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create()
|
|
|
- val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
|
|
|
-
|
|
|
if (tcpModel.action == TcpAction.VoiceAction.CALL) { //有来电
|
|
|
+ val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
|
|
|
//取消掉语音留言录音
|
|
|
RecordHelper.getInstance().stopCancelRecordByOther(true)
|
|
|
|
|
@@ -395,8 +393,6 @@ class WdKeepAliveService : AbsWorkService() {
|
|
|
|
|
|
val intent = Intent()
|
|
|
intent.setClass(this, NewEventListActivity::class.java)
|
|
|
- //intent.putExtra("tcpModelStr", tcpModel.toJson())
|
|
|
- //intent.putExtra("newEvent", true)
|
|
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
|
startActivity(intent)
|
|
|
}).start()
|
|
@@ -409,15 +405,6 @@ class WdKeepAliveService : AbsWorkService() {
|
|
|
playVoiceMsg(interaction)
|
|
|
val msgTcpModel = ImUtil.imRead(Constants.deviceId, interaction.fromDeviceId, interaction.id)
|
|
|
TcpClient.getInstance().sendTcp(msgTcpModel, false, null)
|
|
|
-
|
|
|
- /*NettyClient.instance.sendMsg(msgTcpModel.toJson()).subscribe {
|
|
|
- if (it) {
|
|
|
- Log.d(TAG, "TCP.发送消息完成")
|
|
|
- } else {
|
|
|
- Log.e(TAG, "TCP.发送消息失败")
|
|
|
- HandleTcpConnect.instance.tcpReConnectWithMsgShow()
|
|
|
- }
|
|
|
- }*/
|
|
|
}
|
|
|
} else if (tcpModel.action == TcpAction.EventAction.KEY_CLICK) { // 收到新事件
|
|
|
val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
|
|
@@ -457,7 +444,9 @@ class WdKeepAliveService : AbsWorkService() {
|
|
|
} else {
|
|
|
EventBus.getDefault().post(MessageEvent("update_event", Constants.EVENT_UPDATE_EVENT))
|
|
|
}
|
|
|
- } else if (tcpModel.action == TcpAction.EventAction.CANCEL || tcpModel.action == TcpAction.EventAction.COMPLETED) { // 收到事件取消 或事件完成
|
|
|
+ } else if (tcpModel.action == TcpAction.EventAction.CANCEL
|
|
|
+ || tcpModel.action == TcpAction.EventAction.COMPLETED
|
|
|
+ || tcpModel.action == TcpAction.EventAction.RESPONSED) { // 收到事件取消 或事件完成
|
|
|
//语音播报处理
|
|
|
eventSpeechOut(tcpModel)
|
|
|
//震动提醒
|
|
@@ -599,8 +588,6 @@ class WdKeepAliveService : AbsWorkService() {
|
|
|
if (sosTcpModel.action == TcpAction.SOSAction.CALL || sosTcpModel.action == TcpAction.SOSAction.ROOM_CALL) {
|
|
|
val intent = Intent()
|
|
|
intent.setClass(this, NewEventListActivity::class.java)
|
|
|
- //intent.putExtra("tcpModelStr", tcpModelIn.toJson())
|
|
|
- //intent.putExtra("newEvent", true)
|
|
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
|
startActivity(intent)
|
|
|
}
|
|
@@ -632,8 +619,6 @@ class WdKeepAliveService : AbsWorkService() {
|
|
|
if (sosTcpModel.action == TcpAction.SOSAction.CALL || sosTcpModel.action == TcpAction.SOSAction.ROOM_CALL) {
|
|
|
val intent = Intent()
|
|
|
intent.setClass(this, NewEventListActivity::class.java)
|
|
|
- //intent.putExtra("tcpModelStr", tcpModelIn.toJson())
|
|
|
- //intent.putExtra("newEvent", true)
|
|
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
|
startActivity(intent)
|
|
|
}
|
|
@@ -650,7 +635,6 @@ class WdKeepAliveService : AbsWorkService() {
|
|
|
while (DeviceChannel.calling) { //通话中不处理,一直等待至结束
|
|
|
Thread.sleep(400)
|
|
|
}
|
|
|
- //DeviceChannel.calling = true //置于通话状态中,不可呼叫
|
|
|
Util.wakeUpAndUnlock()
|
|
|
AppUtils.restartApp()
|
|
|
}).start()
|
|
@@ -663,7 +647,6 @@ class WdKeepAliveService : AbsWorkService() {
|
|
|
Thread.sleep(400)
|
|
|
}
|
|
|
|
|
|
- //DeviceChannel.calling = true //置于通话状态中,不可呼叫
|
|
|
Util.wakeUpAndUnlock()
|
|
|
val tcpModel = messageEvent.getMessage() as TcpModel
|
|
|
if (tcpModel.action == TcpAction.DeviceAction.RESTART) {
|
|
@@ -729,7 +712,6 @@ class WdKeepAliveService : AbsWorkService() {
|
|
|
Thread.sleep(400)
|
|
|
}
|
|
|
|
|
|
- //DeviceChannel.calling = true //置于通话状态中,不可呼叫
|
|
|
Util.wakeUpAndUnlock()
|
|
|
val tcpModel = messageEvent.getMessage() as TcpModel
|
|
|
if (tcpModel.action == TcpAction.DeviceAction.APP_UPDATE) {
|
|
@@ -820,12 +802,10 @@ class WdKeepAliveService : AbsWorkService() {
|
|
|
RingPlayHelper.playRingTone(BaseApplication.appContext, R.raw.event, false)
|
|
|
}
|
|
|
} else {
|
|
|
- //MediaPlayHelper.getInstance().playResMusic(R.raw.new_event, 1.0f, false)
|
|
|
RingPlayHelper.playRingTone(BaseApplication.appContext, R.raw.new_event, false)
|
|
|
}
|
|
|
} else if (model.type == TcpType.SOS) {
|
|
|
AppTool.Time.delay(200) {
|
|
|
- //MediaPlayHelper.getInstance().playResMusic(R.raw.sos, 1.0f, true)
|
|
|
RingPlayHelper.playRingTone(BaseApplication.appContext, R.raw.sos, false)
|
|
|
}
|
|
|
} else if (model.action == TcpAction.EventAction.CANCEL) { // 事件取消
|
|
@@ -900,15 +880,6 @@ class WdKeepAliveService : AbsWorkService() {
|
|
|
private fun sendChannelImRead(channelIm: ChannelImDO) {
|
|
|
val imTcpModel = ChannelImUtil.channelImRead(Constants.deviceId, channelIm)
|
|
|
TcpClient.getInstance().sendTcp(imTcpModel, false, null)
|
|
|
-
|
|
|
- /*NettyClient.instance.sendMsg(imTcpModel.toJson()).subscribe {
|
|
|
- if (it) {
|
|
|
- Log.d(TAG, "TCP.发送消息完成")
|
|
|
- } else {
|
|
|
- Log.e(TAG, "TCP.发送消息失败")
|
|
|
- HandleTcpConnect.instance.tcpReConnectWithMsgShow()
|
|
|
- }
|
|
|
- }*/
|
|
|
}
|
|
|
|
|
|
private fun initSpeech() {
|
|
@@ -964,20 +935,10 @@ class WdKeepAliveService : AbsWorkService() {
|
|
|
|
|
|
fun reConnect() {
|
|
|
if (NetHelper.getInstance().getNetworkState(this@WdKeepAliveService) != NetHelper.NETWORK_NONE) {
|
|
|
- /*if (!NettyClient.instance.isConnect()) {
|
|
|
- Log.w(TAG, "TCP.进入重新连接")
|
|
|
- HandleTcpConnect.instance.tcpReConnect()
|
|
|
- }*/
|
|
|
-
|
|
|
if (!TcpClientHandler.getConnected()) {
|
|
|
TcpClient.getInstance().doConnect()
|
|
|
}
|
|
|
- } /*else {
|
|
|
- Thread(Runnable {
|
|
|
- Thread.sleep(5000)
|
|
|
- reConnect()
|
|
|
- }).start()
|
|
|
- }*/
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|