allen пре 3 година
родитељ
комит
5559bb92cc

+ 4 - 1
home/src/main/code/com/wdkl/ncs/android/component/home/activity/WebRTCVoipAudioActivity.kt

@@ -83,7 +83,6 @@ class WebRTCVoipAudioActivity : Activity(), View.OnClickListener, CallSessionCal
         targetId = intent.getStringExtra("targetId")
         Log.i(TAG, "SIP账号$targetId")
         tcpModel = intent.getSerializableExtra("TcpModel") as TcpModel
-        DeviceChannel.callId = if (tcpModel.toId==Constants.deviceId) tcpModel.fromId else tcpModel.toId
         action = intent.getStringExtra(ACTION)
 
         Log.i(TAG, "tcpModel  " + tcpModel.toJson())
@@ -93,10 +92,14 @@ class WebRTCVoipAudioActivity : Activity(), View.OnClickListener, CallSessionCal
                 val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
                 room_number_tv.text = interactionVO.fromFrameFullName
                 bao_mother_name_tv.setText(interactionVO.fromMemberName)
+
+                DeviceChannel.callId = if (interactionVO.fromDeviceId.equals(Constants.deviceId)) interactionVO.toDeviceId else interactionVO.fromDeviceId
             } else if (tcpModel.action === TcpAction.VoiceAction.SUCCESS) {
                 val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
                 room_number_tv.text = interactionVO.toFrameFullName
                 bao_mother_name_tv.setText(interactionVO.toMemberName)
+
+                DeviceChannel.callId = if (interactionVO.fromDeviceId.equals(Constants.deviceId)) interactionVO.toDeviceId else interactionVO.fromDeviceId
             }
         }
 

+ 1 - 1
home/src/main/code/com/wdkl/ncs/android/component/home/activity/WebRTCVoipAudioRingingActivity.kt

@@ -62,8 +62,8 @@ class WebRTCVoipAudioRingingActivity : Activity(), View.OnClickListener {
 
         targetId = intent.getStringExtra("targetId")
         tcpModel = intent.getSerializableExtra("TcpModel") as TcpModel
-        DeviceChannel.callId = if (tcpModel.toId==Constants.deviceId) tcpModel.fromId else tcpModel.toId
         interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
+        DeviceChannel.callId = if (interactionVO.fromDeviceId.equals(Constants.deviceId)) interactionVO.toDeviceId else interactionVO.fromDeviceId
         init()
 
         //震动

+ 2 - 4
home/src/main/code/com/wdkl/ncs/android/component/home/service/WdKeepAliveService.kt

@@ -100,7 +100,6 @@ class WdKeepAliveService : AbsWorkService() {
                     if (tcpModel.action == TcpAction.VoiceAction.SUCCESS) {  //拨出成功
                         Log.i(TAG, "拨出成功 ${interactionVO.fromMemberName} ${interactionVO.id}")
                         DeviceChannel.calling = true
-                        DeviceChannel.callId = if (tcpModel.toId==Constants.deviceId) tcpModel.fromId else tcpModel.toId
                         intent.setClass(this, WebRTCVoipAudioActivity::class.java)
                         intent.putExtra("targetId", interactionVO?.toSipId)
                         intent.putExtra("TcpModel", tcpModel)
@@ -109,7 +108,7 @@ class WdKeepAliveService : AbsWorkService() {
                         startActivity(intent)
                     } else if (tcpModel.action == TcpAction.VoiceAction.CALL) {  //有来电
                         DeviceChannel.calling = true
-                        DeviceChannel.callId = if (tcpModel.toId==Constants.deviceId) tcpModel.fromId else tcpModel.toId
+                        DeviceChannel.callId = if (interactionVO.fromDeviceId.equals(Constants.deviceId)) interactionVO.toDeviceId else interactionVO.fromDeviceId
                         Log.i(TAG, "来电:" + JSON.toJSONString(interactionVO))
                         intent.setClass(this, WebRTCVoipAudioRingingActivity::class.java)
                         intent.putExtra("targetId", interactionVO?.fromSipId)
@@ -125,9 +124,8 @@ class WdKeepAliveService : AbsWorkService() {
                 val tcpModel = messageEvent.getMessage() as TcpModel
                 if (tcpModel.type == TcpType.VOICE && tcpModel.action == TcpAction.VoiceAction.CALL){
                     DeviceChannel.calling = true
-                    DeviceChannel.callId = if (tcpModel.toId==Constants.deviceId) tcpModel.fromId else tcpModel.toId
-
                     val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
+                    DeviceChannel.callId = if (interactionVO.fromDeviceId.equals(Constants.deviceId)) interactionVO.toDeviceId else interactionVO.fromDeviceId
                     val intent = Intent()
                     Log.i(TAG, "来电:" + JSON.toJSONString(interactionVO))
                     intent.setClass(this, WebRTCVoipAudioRingingActivity::class.java)

+ 3 - 1
middleware/src/main/code/com/wdkl/ncs/android/middleware/tcp/TcpClientHandler.java

@@ -88,7 +88,9 @@ public class TcpClientHandler extends SimpleChannelInboundHandler<String> {
 
             TcpModel responseTcpModel = DeviceChannel.handleTcpReceived(tcpModel);
             if (responseTcpModel!=null){
-                ctx.writeAndFlush(tcpModel.toJson());
+                String msg = responseTcpModel.toJson();
+                Log.i(TAG, "TcpClientHandler send msg ===> " + msg);
+                ctx.writeAndFlush(msg);
             } else {
                 ReferenceCountUtil.release(source);
             }

+ 1 - 0
middleware/src/main/code/com/wdkl/ncs/android/middleware/tcp/channel/DeviceChannel.java

@@ -51,6 +51,7 @@ public class DeviceChannel {
                     EventBus.getDefault().post(new MessageEvent(tcpModel, 1));
                 } else if(tcpModel.getAction() == TcpAction.VoiceAction.CALL){
                     if (calling) {
+                        Log.d(TAG,"通话中,来电 " + tcpModel.getFromId() + "<>" + callId);
                         //相同来源,重新建立通话
                         if (tcpModel.getFromId().equals(callId)){
                             EventBus.getDefault().post(new MessageEvent(tcpModel, 11));