|
@@ -231,7 +231,7 @@ class InboundClient:
|
|
|
"""桥接电话"""
|
|
|
self.multi_set_var(device_id1, BRIDGE_VARIABLES)
|
|
|
self.multi_set_var(device_id2, BRIDGE_VARIABLES)
|
|
|
- self.con.bgapi(BRIDGE, device_id1 + SPACE + device_id2)
|
|
|
+ self.bgapi(BRIDGE, arg=device_id1 + SPACE + device_id2, desc="bridge_call")
|
|
|
|
|
|
def transfer_call(self, _from, _to):
|
|
|
"""转接"""
|
|
@@ -324,7 +324,7 @@ class InboundClient:
|
|
|
val
|
|
|
]
|
|
|
command = ' '.join(builder)
|
|
|
- self.con.bgapi(command, EMPTY)
|
|
|
+ self.bgapi(command, desc ="set_var")
|
|
|
|
|
|
def multi_set_var(self, uuid, params):
|
|
|
builder = [
|
|
@@ -335,7 +335,7 @@ class InboundClient:
|
|
|
builder1.append(k + "="+v)
|
|
|
builder.append(';'.join(builder1))
|
|
|
command = ''.join(builder)
|
|
|
- self.con.bgapi(command, EMPTY)
|
|
|
+ self.bgapi(command, desc="multi_set_var")
|
|
|
|
|
|
def record(self, uuid, action, path, limit):
|
|
|
builder = [
|
|
@@ -375,19 +375,8 @@ class InboundClient:
|
|
|
device_id,
|
|
|
f" -both 'set:hangup_after_bridge=false,set:park_after_bridge=true,set:{SIP_HEADER}{sipHeaderHoldMusic}={call_id},park:' inline "
|
|
|
]
|
|
|
- _con = None
|
|
|
- try:
|
|
|
- arg = ''.join(builder)
|
|
|
- _con = ESL.ESLconnection(self.host, self.port, self.password)
|
|
|
- if _con.connected():
|
|
|
- print('debugger::bridge_break, arg=%s'%arg, flush=True)
|
|
|
- e = _con.api(TRANSFER, arg)
|
|
|
- print('debugger::bridge_break success, arg=%s, event=%s' % (arg, e.serialize('json')), flush=True)
|
|
|
- except:
|
|
|
- traceback.print_exc()
|
|
|
- finally:
|
|
|
- if _con:
|
|
|
- _con.disconnect()
|
|
|
+ arg = ''.join(builder)
|
|
|
+ self.api(TRANSFER, arg, "bridge_break")
|
|
|
|
|
|
def play_file(self, call_id, device_id, file, sync):
|
|
|
"""放音"""
|
|
@@ -419,15 +408,30 @@ class InboundClient:
|
|
|
" ",
|
|
|
SMF_ALEG
|
|
|
]
|
|
|
+ arg = ''.join(builder)
|
|
|
+ self.api(UUID_BROADCAST, arg, "hold_play")
|
|
|
+
|
|
|
+ def api(self, command, arg=EMPTY, desc=""):
|
|
|
+ _con = None
|
|
|
+ try:
|
|
|
+ _con = ESL.ESLconnection(self.host, self.port, self.password)
|
|
|
+ if _con.connected():
|
|
|
+ e = _con.api(command, arg)
|
|
|
+ print('debugger::%s success, arg=%s, event=%s' % (desc, command + ' ' + arg, e.serialize('json')),
|
|
|
+ flush=True)
|
|
|
+ except:
|
|
|
+ traceback.print_exc()
|
|
|
+ finally:
|
|
|
+ if _con:
|
|
|
+ _con.disconnect()
|
|
|
+
|
|
|
+ def bgapi(self, command, arg=EMPTY, desc=""):
|
|
|
_con = None
|
|
|
try:
|
|
|
- arg = ''.join(builder)
|
|
|
- print('debugger::hold_play, device_id=%s, play=%s' % (device_id, play), flush=True)
|
|
|
_con = ESL.ESLconnection(self.host, self.port, self.password)
|
|
|
if _con.connected():
|
|
|
- print('debugger::hold_play, arg=%s' % arg, flush=True)
|
|
|
- e = _con.api(UUID_BROADCAST, arg)
|
|
|
- print('debugger::hold_play success, arg=%s, event=%s' % (arg, e.serialize('json')), flush=True)
|
|
|
+ e = _con.bgapi(command, arg)
|
|
|
+ print('debugger::%s success, arg=%s, event=%s' % (desc, command + ' '+arg, e.serialize('json')), flush=True)
|
|
|
except:
|
|
|
traceback.print_exc()
|
|
|
finally:
|