|
@@ -26,32 +26,28 @@ class ChannelHangupHandler(EslEventHandler):
|
|
|
self.call_service = CallService(inbound_client, logger)
|
|
|
|
|
|
def handle(self, address, event, coreUUID):
|
|
|
- print(json.loads(event.serialize('json')))
|
|
|
+ print(json.loads(event.serialize('json')), end="", flush=True)
|
|
|
try:
|
|
|
call_id = EslEventUtil.getCallId(event)
|
|
|
- print('debugger::call_id is ', call_id)
|
|
|
- sys.stdout.flush() # 强制刷新输出缓冲区
|
|
|
+ print('debugger::call_id is ', call_id, end="", flush=True)
|
|
|
if not call_id:
|
|
|
self.release(event)
|
|
|
- print("call_id is null")
|
|
|
+ print("call_id is null", end="", flush=True)
|
|
|
return
|
|
|
call = Cache.get_call_info(call_id)
|
|
|
- print('debugger::call_info is ', call)
|
|
|
- sys.stdout.flush() # 强制刷新输出缓冲区
|
|
|
+ print('debugger::call_info is ', call, end="", flush=True)
|
|
|
if not call:
|
|
|
- print("call:%s is null", call_id)
|
|
|
+ print("call:%s is null", call_id, end="", flush=True)
|
|
|
return
|
|
|
device_id = EslEventUtil.getDeviceId(event)
|
|
|
device = call.device_info_map.get(device_id)
|
|
|
- print('debugger::device_id is ', device_id)
|
|
|
- sys.stdout.flush() # 强制刷新输出缓冲区
|
|
|
+ print('debugger::device_id is ', device_id, end="", flush=True)
|
|
|
if not device:
|
|
|
- print("device:%s is null", device_id)
|
|
|
+ print("device:%s is null", device_id, end="", flush=True)
|
|
|
return
|
|
|
|
|
|
count = len(call.device_list)
|
|
|
- print('debugger::ChannelHangupHandler, call_id=%s, device_id=%s, count=%s'% (call_id, device_id, count))
|
|
|
- sys.stdout.flush() # 强制刷新输出缓冲区
|
|
|
+ print('debugger::ChannelHangupHandler, call_id=%s, device_id=%s, count=%s'% (call_id, device_id, count), end="", flush=True)
|
|
|
try:
|
|
|
call.device_list.remove(device_id)
|
|
|
except:
|
|
@@ -82,15 +78,14 @@ class ChannelHangupHandler(EslEventHandler):
|
|
|
if device.record_start_time:
|
|
|
device.record_time = int(device.end_time) - int(device.record_start_time)
|
|
|
call.device_info_map[device.device_id] = device
|
|
|
- print('debugger::ChannelHangupHandler, hangup_reason=%s, device_type=%s' % (hangup_reason, device.device_type))
|
|
|
+ print('debugger::ChannelHangupHandler, hangup_reason=%s, device_type=%s' % (hangup_reason, device.device_type), end="", flush=True)
|
|
|
# 如果是转人工
|
|
|
- sys.stdout.flush() # 强制刷新输出缓冲区
|
|
|
if 'transferToAgent' == hangup_reason and DeviceType.ROBOT.code == device.device_type:
|
|
|
call.answer_flag = AnswerFlag.TRANSFER_TO_AGENT.code
|
|
|
service_id = EslEventUtil.getLIBRAServiceId(event)
|
|
|
Cache.add_call_info(call)
|
|
|
+ print('debugger::ChannelHangupHandler, transferToAgent, service_id=%s' % (service_id), end="", flush=True)
|
|
|
self.acd_service.transfer_to_agent(call, device, service_id)
|
|
|
- sys.stdout.flush() # 强制刷新输出缓冲区
|
|
|
return
|
|
|
|
|
|
# 如果有下一步
|
|
@@ -108,7 +103,6 @@ class ChannelHangupHandler(EslEventHandler):
|
|
|
# 判断挂机方向 && 更新缓存
|
|
|
self.hangup_dir(call, device, cause)
|
|
|
Cache.add_call_info(call)
|
|
|
- sys.stdout.flush() # 强制刷新输出缓冲区
|
|
|
except:
|
|
|
traceback.print_exc()
|
|
|
|