|
@@ -270,12 +270,15 @@ class InboundClient:
|
|
delay_action = DelayAction(call_id=call_id, device_id=device_id)
|
|
delay_action = DelayAction(call_id=call_id, device_id=device_id)
|
|
Cache.add_delay_message(DelayActionEnum.CALL_TIMEOUT_HANGUP.code, delay_action, timeouts=timeout)
|
|
Cache.add_delay_message(DelayActionEnum.CALL_TIMEOUT_HANGUP.code, delay_action, timeouts=timeout)
|
|
|
|
|
|
- def send_args(self, device_id, name, arg):
|
|
|
|
|
|
+ def send_args(self, device_id, name, arg, con=None):
|
|
msg = ESL.ESLevent("sendmsg", device_id)
|
|
msg = ESL.ESLevent("sendmsg", device_id)
|
|
msg.addHeader("call-command", EXECUTE)
|
|
msg.addHeader("call-command", EXECUTE)
|
|
msg.addHeader("execute-app-name", name)
|
|
msg.addHeader("execute-app-name", name)
|
|
msg.addHeader("execute-app-arg", arg)
|
|
msg.addHeader("execute-app-arg", arg)
|
|
- self.con.sendEvent(msg)
|
|
|
|
|
|
+ if con:
|
|
|
|
+ con.sendEvent(msg)
|
|
|
|
+ else:
|
|
|
|
+ self.con.sendEvent(msg)
|
|
|
|
|
|
def bridge_call(self, call_id, device_id1, device_id2):
|
|
def bridge_call(self, call_id, device_id1, device_id2):
|
|
"""桥接电话"""
|
|
"""桥接电话"""
|
|
@@ -303,16 +306,22 @@ class InboundClient:
|
|
msg.addHeader("execute-app-name", HANGUP)
|
|
msg.addHeader("execute-app-name", HANGUP)
|
|
msg.addHeader("execute-app-arg", NORMAL_CLEARING)
|
|
msg.addHeader("execute-app-arg", NORMAL_CLEARING)
|
|
msg.addHeader("async", "true")
|
|
msg.addHeader("async", "true")
|
|
|
|
+ _con = None
|
|
try:
|
|
try:
|
|
- print("hangup_call挂机1 hangup call: %s, device: %s, ctiCauseEnum: %s"% (call_id, device_id, case_enum), flush=True)
|
|
|
|
- arg = ''.join([EslEventUtil.SIP_H_P_LIBRA_HANGUP_CAUSE,"=", case_enum.description])
|
|
|
|
- print("hangup_call挂机2 hangup call: %s, device: %s, arg: %s"% (call_id, device_id, arg), flush=True)
|
|
|
|
- self.send_args(device_id, SET, arg)
|
|
|
|
- print("hangup_call挂机3 hangup call: %s, device: %s, arg: %s"% (call_id, device_id, arg), flush=True)
|
|
|
|
- self.con.sendEvent(msg)
|
|
|
|
- print("hangup_call挂机4 hangup call: %s, device: %s, arg: %s"% (call_id, device_id, arg), flush=True)
|
|
|
|
|
|
+ _con = ESL.ESLconnection(self.host, self.port, self.password)
|
|
|
|
+ if _con.connected():
|
|
|
|
+ print("hangup_call挂机1 hangup call: %s, device: %s, ctiCauseEnum: %s" % (call_id, device_id, case_enum), flush=True)
|
|
|
|
+ arg = ''.join([EslEventUtil.SIP_H_P_LIBRA_HANGUP_CAUSE, "=", case_enum.description])
|
|
|
|
+ print("hangup_call挂机2 hangup call: %s, device: %s, arg: %s" % (call_id, device_id, arg), flush=True)
|
|
|
|
+ self.send_args(device_id, SET, arg, con=_con)
|
|
|
|
+ print("hangup_call挂机3 hangup call: %s, device: %s, arg: %s" % (call_id, device_id, arg), flush=True)
|
|
|
|
+ _con.sendEvent(msg)
|
|
|
|
+ print("hangup_call挂机4 hangup call: %s, device: %s, arg: %s" % (call_id, device_id, arg), flush=True)
|
|
except:
|
|
except:
|
|
traceback.print_exc()
|
|
traceback.print_exc()
|
|
|
|
+ finally:
|
|
|
|
+ if _con:
|
|
|
|
+ _con.disconnect()
|
|
|
|
|
|
def broadcast(self, uuid, path, smf):
|
|
def broadcast(self, uuid, path, smf):
|
|
builder = [
|
|
builder = [
|