Browse Source

播放等待音调试

774056846 4 months ago
parent
commit
3b088153e1

+ 13 - 1
src/core/callcenter/cache.py

@@ -143,4 +143,16 @@ def get_delay_message(action):
 
 def lock_delay_action(val):
     key = CTI_ENGINE_DELAY_ACTION_LOCK % val
-    return redis_handler.redis.set(key, "1", ex=1000*10, nx=True)
+    return redis_handler.redis.set(key, "1", ex=60*10, nx=True)
+
+def set_need_play_hold_music(call_id):
+    key = NEED_PLAY_HOLD_MUSIC % call_id
+    return redis_handler.redis.set(key, "1", ex=60 * 1, nx=True)
+
+def get_need_play_hold_music(call_id):
+    key = NEED_PLAY_HOLD_MUSIC % call_id
+    return redis_handler.redis.get(key)
+
+def del_need_play_hold_music(call_id):
+    key = NEED_PLAY_HOLD_MUSIC % call_id
+    delete_key(key)

+ 1 - 1
src/core/callcenter/call.py

@@ -56,7 +56,7 @@ class CallService:
         custom_device_id = devices[0]
         print('debugger::hold, custom_device_id=%s'%custom_device_id, flush=True)
         self.client.bridge_break(custom_device_id)
-        self.client.hold_play(custom_device_id, HOLD_MUSIC_PATH)
+        Cache.set_need_play_hold_music(call_info.call_id)
         print('debugger::hold success custom_device_id=%s'%custom_device_id, flush=True)
 
     def cancel_hold(self, call_info: CallInfo, device_id):

+ 1 - 1
src/core/callcenter/constant.py

@@ -80,7 +80,7 @@ START_AGENT_NUM = "1000"
 DELAY_ACTION_BATCH_SIZE = 10
 CTI_ENGINE_DELAY_ACTION = "DELAY:ACTION:%s"
 CTI_ENGINE_DELAY_ACTION_LOCK = "DELAY:ACTION:LOCK:%s"
-
+NEED_PLAY_HOLD_MUSIC = "CTI:ENGINE:NEED:HOLD:%s"
 
 def get_json_dict(json_string):
     data = json_string

+ 2 - 2
src/core/callcenter/esl/client.py

@@ -413,7 +413,7 @@ class InboundClient:
         """拆线"""
         builder = [
             device_id,
-            "  -both 'set:hangup_after_bridge=false,set:park_after_bridge=true,park:' inline "
+            "  -both 'set:hangup_after_bridge=false,set:park_after_bridge=true,set:" + SIP_HEADER + sipHeaderHoldMusic + "=true,park:' inline "
         ]
         arg = ''.join(builder)
         print('debugger::bridge_break, arg=%s'%arg, flush=True)
@@ -453,7 +453,7 @@ class InboundClient:
         print('debugger::hold_play, device_id=%s, play=%s' % (device_id, play), flush=True)
         arg = ''.join(builder)
         print('debugger::hold_play, arg=%s' % arg, flush=True)
-        self.con.api(UUID_BROADCAST, arg)
+        self.con.bgapi(UUID_BROADCAST, arg)
         print('debugger::hold_play success, arg=%s' % arg, flush=True)
 
     def play_timeout(self, call_id, timeout):

+ 32 - 0
src/core/callcenter/esl/handler/channel_park_handler.py

@@ -3,6 +3,11 @@
 
 import json
 import src.core.callcenter.cache as Cache
+from src.core.callcenter.constant import HOLD_MUSIC_PATH
+from src.core.callcenter.enumeration import DeviceType
+from src.core.callcenter.esl.constant.esl_constant import SIP_HEADER
+from src.core.callcenter.esl.constant.sip_header_constant import sipHeaderHoldMusic
+from src.core.callcenter.esl.utils.esl_event_util import *
 from src.core.callcenter.esl.annotation import EslEventName
 from src.core.callcenter.esl.constant.event_names import CHANNEL_PARK
 from src.core.callcenter.esl.handler.esl_event_handler import EslEventHandler
@@ -20,6 +25,33 @@ class ChannelParkHandler(EslEventHandler):
             self.process_fxo_calling(event)
             return
 
+        call_id = getCallId(event)
+        device_id = getUniqueId(event)
+        need_hold_music = getVariableNeedHoldMusic(event)
+        print("park播放等待音标识 callId: %s deviceId: %s needHoldMusic:%s",call_id,device_id,need_hold_music, flush=True)
+        if need_hold_music:
+            self.play_hold_music(event)
+            return
+
+    def play_hold_music(self, event):
+        call_id = getCallId(event)
+        device_id = getUniqueId(event)
+        print('debugger, ChannelParkHandler, call_id=%s, device_id=%s'%(call_id, device_id), flush=True)
+        if not call_id or not device_id:
+            return
+        call_info = Cache.get_call_info(call_id)
+        if not call_info:
+            print("CHANNEL_PARK callInfo is null", flush=True)
+            return
+
+        device_info = call_info.device_info_map.get(device_id)
+        hold = Cache.get_need_play_hold_music(call_id)
+        print('debugger, ChannelParkHandler, hold=%s, device_info=%s' % (hold, device_info), flush=True)
+        if hold and device_info.device_type == DeviceType.CUSTOMER.code:
+            self.inbound_client.hold_play(device_id, HOLD_MUSIC_PATH)
+            Cache.del_need_play_hold_music(call_id)
+            self.inbound_client.set_var(device_id, SIP_HEADER + sipHeaderHoldMusic, "false")
+
     def process_fxo_calling(self, event):
         kwargs = json.loads(event.serialize('json'))
         destination = self.bot_agent.register(**kwargs)