|
@@ -45,7 +45,7 @@ class InboundClient:
|
|
self.logger = app.logger
|
|
self.logger = app.logger
|
|
self.bot_agent = agent
|
|
self.bot_agent = agent
|
|
self.cache = Cache(app)
|
|
self.cache = Cache(app)
|
|
- self.callback = Callback(app)
|
|
|
|
|
|
+ self.callback = Callback(app, self.thread_num)
|
|
self.dataHandleServer = DataHandleServer(app)
|
|
self.dataHandleServer = DataHandleServer(app)
|
|
self.handler_table = self.scan_esl_event_handlers()
|
|
self.handler_table = self.scan_esl_event_handlers()
|
|
self.default_event_handler = DefaultEslEventHandler(self, self.bot_agent)
|
|
self.default_event_handler = DefaultEslEventHandler(self, self.bot_agent)
|
|
@@ -100,7 +100,7 @@ class InboundClient:
|
|
time.sleep(3)
|
|
time.sleep(3)
|
|
self.start()
|
|
self.start()
|
|
else:
|
|
else:
|
|
- # threading.Thread(target=self.process_esl_event, args=(e,)).start()
|
|
|
|
|
|
+ registry.FLASK_ACTIVE_THREADS.set(threading.active_count())
|
|
self.choose_thread_pool_executor(e).submit(self.process_esl_event, e)
|
|
self.choose_thread_pool_executor(e).submit(self.process_esl_event, e)
|
|
|
|
|
|
def choose_thread_pool_executor(self, e):
|
|
def choose_thread_pool_executor(self, e):
|
|
@@ -183,6 +183,7 @@ class InboundClient:
|
|
self.cache.add_call_info(call_info)
|
|
self.cache.add_call_info(call_info)
|
|
self.hangup_call(call_id, device_id, CallCause.CALL_TIMEOUT)
|
|
self.hangup_call(call_id, device_id, CallCause.CALL_TIMEOUT)
|
|
self.dataHandleServer.update_record(call_id, status= 0)
|
|
self.dataHandleServer.update_record(call_id, status= 0)
|
|
|
|
+
|
|
def exec_when_play_timeout(self, call_id):
|
|
def exec_when_play_timeout(self, call_id):
|
|
call_info = self.cache.get_call_info(call_id)
|
|
call_info = self.cache.get_call_info(call_id)
|
|
if not call_info or not call_info.next_commands:
|
|
if not call_info or not call_info.next_commands:
|
|
@@ -210,6 +211,7 @@ class InboundClient:
|
|
next_command = NextCommand(device_id = device_id, next_type=NextType.NEXT_HANGUP.code)
|
|
next_command = NextCommand(device_id = device_id, next_type=NextType.NEXT_HANGUP.code)
|
|
call_info.next_commands = [next_command]
|
|
call_info.next_commands = [next_command]
|
|
self.cache.add_call_info(call_info)
|
|
self.cache.add_call_info(call_info)
|
|
|
|
+ self.dataHandleServer.update_record(call_id, status= 0)
|
|
self.logger.info("waitingTimeOut 开始播放结束音乐 callId:%s customerDeviceId:%s playFile:%s", call_id,
|
|
self.logger.info("waitingTimeOut 开始播放结束音乐 callId:%s customerDeviceId:%s playFile:%s", call_id,
|
|
device_id, WaitingHangupMusicPath)
|
|
device_id, WaitingHangupMusicPath)
|
|
|
|
|
|
@@ -491,6 +493,7 @@ class InboundClient:
|
|
v.shutdown()
|
|
v.shutdown()
|
|
self.con.disconnect()
|
|
self.con.disconnect()
|
|
self.is_stopping = True
|
|
self.is_stopping = True
|
|
|
|
+ self.callback.stop()
|
|
|
|
|
|
|
|
|
|
class OutboundClient:
|
|
class OutboundClient:
|
|
@@ -555,29 +558,6 @@ class OutboundClient:
|
|
registry.CALL_INCOMING_REQUESTS.labels(f"{_bucket_call_type}").inc()
|
|
registry.CALL_INCOMING_REQUESTS.labels(f"{_bucket_call_type}").inc()
|
|
self.server.dataHandleServer.create_record(call_id, caller_number, _bucket_call_type, service_category=service_category, destination=destination)
|
|
self.server.dataHandleServer.create_record(call_id, caller_number, _bucket_call_type, service_category=service_category, destination=destination)
|
|
|
|
|
|
- # # 检查白名单
|
|
|
|
- # if caller_number in whitelist:
|
|
|
|
- # agents = self.server.load_agent_monitor()
|
|
|
|
- # destination = random.choice(agents) # 随机取一个坐席号
|
|
|
|
- # # 直接转接到人工坐席
|
|
|
|
- # self.server.logger.info( "Caller %s is in whitelist, agents: %s, destination: %s"% (caller_number, agents, destination))
|
|
|
|
- # call_info['type']= 0
|
|
|
|
- # call_info['agent_num'] = destination
|
|
|
|
- # else:
|
|
|
|
- # #转到ai机器人
|
|
|
|
- # destination = self.server.agent.register(**kwargs)
|
|
|
|
- # self.server.logger.info("device_id=%s, destination=%s, new_device_id=%s"% (device_id, destination, new_device_id))
|
|
|
|
- # call_info['type'] = 1
|
|
|
|
- # call_info['service_category'] = 1
|
|
|
|
- # call_info['user_id'] = destination
|
|
|
|
- # call_info['user_name'] = f"机器人{destination}"
|
|
|
|
- # self.build_call_info(call_id, device_id, new_device_id, str(destination), **kwargs)
|
|
|
|
- # self.server.cache.add_device_user_part(device_id, destination)
|
|
|
|
- # con.execute("bridge", "{sip_h_P-LIBRA-CallId=%s,sip_h_P-LIBRA-DeviceId=%s,origination_uuid=%s}user/%s"%(call_id, new_device_id, new_device_id, destination), device_id)
|
|
|
|
-
|
|
|
|
- # self.server.dataHandleServer.create_record(call_info)
|
|
|
|
-
|
|
|
|
-
|
|
|
|
# destination = "user/1001"
|
|
# destination = "user/1001"
|
|
# msg = ESL.ESLevent("sendmsg", uuid)
|
|
# msg = ESL.ESLevent("sendmsg", uuid)
|
|
# msg.addHeader("call-command", "execute")
|
|
# msg.addHeader("call-command", "execute")
|