|
@@ -17,12 +17,30 @@ class InboundClient:
|
|
|
|
|
|
def start(self):
|
|
def start(self):
|
|
if self.con.connected():
|
|
if self.con.connected():
|
|
|
|
+ print('inbound esl connected ... ')
|
|
self.con.events('plain', 'all')
|
|
self.con.events('plain', 'all')
|
|
while not self.is_stopping:
|
|
while not self.is_stopping:
|
|
e = self.con.recvEvent()
|
|
e = self.con.recvEvent()
|
|
if e:
|
|
if e:
|
|
- print(e)
|
|
|
|
|
|
+ print(json.loads(e.serialize('json')))
|
|
# print(e.serialize('json'))
|
|
# print(e.serialize('json'))
|
|
|
|
+ event_name = e.getHeader("Event-Name")
|
|
|
|
+ if event_name == "CHANNEL_PARK":
|
|
|
|
+ # 获取通话的 UUID
|
|
|
|
+ call_uuid = e.getHeader("Unique-ID")
|
|
|
|
+ print(f"Incoming call with UUID: {call_uuid}")
|
|
|
|
+
|
|
|
|
+ self.con.execute("bridge", "user/1001", call_uuid)
|
|
|
|
+
|
|
|
|
+ destination = "user/1001"
|
|
|
|
+ # msg = ESL.ESLevent("sendmsg", call_uuid)
|
|
|
|
+ # msg.addHeader("call-command", "execute")
|
|
|
|
+ # msg.addHeader("execute-app-name", "bridge")
|
|
|
|
+ # msg.addHeader("execute-app-arg", destination)
|
|
|
|
+ # msg.addHeader("execute-app-arg", destination)
|
|
|
|
+ # # 发送消息以执行 bridge 操作
|
|
|
|
+ # self.con.sendEvent(msg)
|
|
|
|
+ print(f"Call {call_uuid} is bridged to {destination}")
|
|
|
|
|
|
def stop(self):
|
|
def stop(self):
|
|
self.is_stopping = True
|
|
self.is_stopping = True
|
|
@@ -33,12 +51,25 @@ class OutboundClient:
|
|
@staticmethod
|
|
@staticmethod
|
|
def ack(esl, con):
|
|
def ack(esl, con):
|
|
info = con.getInfo()
|
|
info = con.getInfo()
|
|
- print(info.serialize('json'))
|
|
|
|
|
|
+ print(json.loads(info.serialize('json')))
|
|
event_name = info.getHeader("Event-Name")
|
|
event_name = info.getHeader("Event-Name")
|
|
uuid = info.getHeader("unique-id")
|
|
uuid = info.getHeader("unique-id")
|
|
print(uuid, event_name)
|
|
print(uuid, event_name)
|
|
- con.execute("answer", "", uuid)
|
|
|
|
- con.execute("playback", "/Users/davidliu/sip/pjproject/voip/test111.wav", uuid)
|
|
|
|
|
|
+
|
|
|
|
+ # destination = "user/1001"
|
|
|
|
+ # msg = ESL.ESLevent("sendmsg", uuid)
|
|
|
|
+ # msg.addHeader("call-command", "execute")
|
|
|
|
+ # msg.addHeader("execute-app-name", "bridge")
|
|
|
|
+ # msg.addHeader("execute-app-arg", destination)
|
|
|
|
+ # # 发送消息以执行 bridge 操作
|
|
|
|
+ # con.sendEvent(msg)
|
|
|
|
+ # print(f"Call {uuid} is bridged to {destination}")
|
|
|
|
+
|
|
|
|
+ # con.execute("park", "", uuid)
|
|
|
|
+ con.execute("bridge", "user/1001", uuid)
|
|
|
|
+
|
|
|
|
+ # con.execute("answer", "", uuid)
|
|
|
|
+ # con.execute("playback", "/Users/davidliu/sip/pjproject/voip/test111.wav", uuid)
|
|
|
|
|
|
con.disconnect()
|
|
con.disconnect()
|
|
|
|
|
|
@@ -70,8 +101,8 @@ class OutboundClient:
|
|
|
|
|
|
def main():
|
|
def main():
|
|
on = InboundClient()
|
|
on = InboundClient()
|
|
- out = OutboundClient()
|
|
|
|
- threading.Thread(target=out.start, args=()).start()
|
|
|
|
|
|
+ # out = OutboundClient()
|
|
|
|
+ # threading.Thread(target=out.start, args=()).start()
|
|
threading.Thread(target=on.start, args=()).start()
|
|
threading.Thread(target=on.start, args=()).start()
|
|
|
|
|
|
if __name__ == '__main__':
|
|
if __name__ == '__main__':
|