Home

Resources

Products

Developers

Main • YAYPMBridgeAndThenUnbridge

This script is given as an example, don't forget to change some information such as yate's extmodule binding ip address and port.

This script will:

 1 - make a phone call to 'jmfoucher'
 2 - play a sound to jmfoucher
 3 - wait for DTMF "1"
 4 - once "1" is pressed, toto is called
 5 - when toto answers, toto and jmfoucher are bridged
 6 - after 3 seconds, toto and jmfoucher will be unbridged (the two new channels are independant)
 7 - two different sounds are played on the different channels


 #!/usr/bin/python
 from twisted.internet import reactor, defer
 from yaypm import TCPDispatcherFactory, AbandonedException
 from yaypm.flow import go, getResult

 from yaypm.utils import ConsoleFormatter

 import logging, yaypm

 logger = logging.getLogger("test3")

 class myTest(object):

     def __init__(self, client):
         logger.debug(">>> myTest.__init__()")
         self.client = client
         self.run()

     def run(self):
         logger.debug(">>> myTest.run()")
         go(self.test())


     def test(self):
         logger.debug(">>> myTest.test()")

         firsttime = True 

         yield self.client.installMsgHandler("call.route", prio = 50)
         getResult()
         yield self.client.installWatchHandler("call.answered")
         getResult()
         yield self.client.installWatchHandler("chan.hangup")
         getResult()

         execute = self.client.msg("call.execute",
          {"callto": "dumb/",
           "caller": "appelant",
           "target": "jmfoucher",
           "sip_prout": "value",
           "osip_toto": "tata"
          })
         yield execute.dispatch()
         if not getResult():
             logger.warn("can't create monitor connection on jmfoucher")
             monitor = None
         else:
             logger.debug("can monitor jmfoucher")
             try: 
                 end = self.client.onwatch(
                     "chan.hangup",
                     lambda m, callid = execute["id"] : m["id"] == callid)

                 yield self.client.onwatch(
                     "call.answered",
                     lambda m : m["id"] ==  execute["targetid"],
                     until = end)
                 getResult()
                 logger.debug("Monitor connection answered.") 

                 dumbid = execute["id"]
                 monitorid = execute["targetid"]
                 callid = execute["id"]
                 logger.debug("callid = s" % (callid, monitorid))

                 logger.debug("on joue le son")

                 self.client.msg("chan.masquerade",
                 {"message" : "chan.attach",
                  #"id": monitorid,
                  "id": callid,
                  "source": "wave/play/../../sounds/wp_star_seller_ask.wav"}).enqueue()

                 logger.debug("le son est parti")


                 while True:

                     logger.debug("dans le while True")

                     yield self.client.onmsg(
                         "chan.dtmf",
                         #lambda m : m["id"] == callid,
                         lambda m : m["id"] == monitorid,
                         end)
                     dtmf = getResult()

                     logger.debug("Dtmf  dtmf["text"])

                     dtmf.ret(True)

                     if dtmf["text"] == "1":
                         if firsttime:
                             firsttime = False

                             self.client.msg("chan.masquerade",
                                 {"message" : "chan.attach",
                                  "id": callid,
                                  "source": "wave/play/../../sounds/wp_star_seller_wait.wav"}).enqueue()


                             execute = self.client.msg("call.execute",
                              {"callto": "dumb/",
                               "caller": "jmfoucher",
                               "target": 'toto'})
                             yield execute.dispatch()
                             if not getResult():
                                 logger.debug("FAILURE")
                             else:
                                 logger.debug("SUCCESS")
                                 callid2 = execute["id"]
                                 targetid2 = execute["targetid"]
                                 logger.debug("callid=s" % (callid, monitorid))
                                 logger.debug("callid2=s" % (callid2, targetid2))


                                 end = self.client.onmsg("chan.hangup",
                                     lambda m, callid = targetid2 : m["id"] == callid, autoreturn = True)

                                 yield self.client.onwatch("call.answered",
                                     lambda m : m["targetid"] == callid2, until = end)

                                 answered = getResult()
                                 logger.debug("answered= answered)

                                 logger.debug("on appelle self.conf")
                                 logger.debug("callid = s" % (callid, callid2))

                                 connect = self.client.msg(
                                     "chan.connect",
                                     {"id": monitorid,
                                      "targetid": targetid2})
                                 yield connect.dispatch()

                                 if getResult():
                                     logger.debug("connect SUCCESS")
                                 else:
                                     logger.debug("connect FAILURE")

                                 def sound():
                                     go(sound2())

                                 def sound2():
                                     logger.debug("dans sound")

                                     transfer = self.client.msg("chan.masquerade",
                                                         {"message": "call.transfer",
                                                          "id": monitorid,
                                                          "to": "wave/play/../../sounds/accueil_court.wav",
                                                          "peerto": "wave/play/../../sounds/wp_star_seller_wait.wav"
                                                         })
                                     yield transfer.dispatch()
                                     if not getResult():
                                         logger.debug("transfer failure")
                                     else:
                                         logger.debug("transfer success")


                                 reactor.callLater(3, sound)


                             #yield yate.msg("call.drop", {"id": targetid}).dispatch()
                             #getResult()




             except AbandonedException, e:
                 logger.debug("Call  callid)




 def start(host, port):
     logger.debug("dans start")

     local_addr = remote_addr = host
     local_port = remote_port = port

     #go(route(yate))
     def start_client(client_yate):
         logger.debug("client started");
         myTest(client_yate)

     client_factory = TCPDispatcherFactory(start_client)

     reactor.connectTCP(local_addr, local_port, client_factory)

 if __name__ == _main_:

     hdlr = logging.StreamHandler()
     formatter = ConsoleFormatter('%(name)s %(levelname)s %(message)s')
     hdlr.setFormatter(formatter)

     yaypm.logger.addHandler(hdlr)
     yaypm.logger.setLevel(logging.DEBUG)
     #yaypm.flow.logger_flow.setLevel(logging.DEBUG)
     yaypm.logger_messages.setLevel(logging.DEBUG)
     yaypm.logger_messages.setLevel(logging.INFO) 

     logger.setLevel(logging.DEBUG)
     logger.addHandler(hdlr)

     #f = TCPDispatcherFactory(start)
     #reactor.connectTCP("192.168.4.87", 5039, f)
     start("192.168.4.87", 5039)
     reactor.run()

July 2014:
Yate 5.4 and YateBTS 4 launched. Added JSON and DNS support in Javascript, Handover support in YateBTS.

March 2014:
YateBTS 2.0 launched. Added authentication and WebGUI. Added USSD support in commercial version.

March 2014:
Yate 5.2 launched. Better JavaScript support and a fixed memory leak.

Jan 2014:
YateBTS 1.0 launched. The first GSM Basestation which works with an IMS/VoLTE core network.

Jan 2014:
Yate 5.1 launched. Better JavaScript support and added libygsm. Elisa chatbot added in RManager

Oct 2013:
OpenHSS is the Yate based HLR/HSS solution for MVNO and LTE carriers.

Oct 2013:
Yate 5 released. Added IPv6 support in SIP for LTE. Improved JavaScript support. Download NOW

Jan 2013:
Yate 4.3 released: Added XML support in Javascript. SCCP - GTT routing between different networks. Stability improvements.
Download NOW

Aug 2012:
Yate 4.2 released: SIP flood protection. Better Jabber/Google Voice support. Usable Javascript. Fixed SIGTRAN links fluctuations.
Download NOW

Apr 2012:
YateClient was accepted in the Mac Store.

Yate 4.1 released: better Gvoice support, iSAC codec, support for new Wanpipe drivers. Fixes T.38 and Mac client issues.

Mar 2012:
SS7Cloud is launched today, 1st March, 2012, by NullTeam, Yate creators. Having all you need to be a US CLEC, it brings SS7 services in a cloud.

Feb 2012:
Yate 4.0 released.
SCCP, TCAP, MAP and CAMEL, TCP and TLS in SIP, Javascript fast prototyping of telephony applications and brand new face for YateClient.

Nov 2011:
Here is a video that, quote "demonstrates the truly awesome power of the YATE engine, as it easily handles 3 simultaneous calls to an audio player application including dtmf (button press) handling "(from PaintedRockComm).

Nov 2011:
Yate will attend ORR - OPENRHEINRUHR (November 12 - 13).

04 May 2011:
sipgate chooses open source project Yate for core infrastructure.

12 Apr 2011:
Yate 3.3.2 released.
Fix for Jingle calls to Google Voice dropping after 5 minutes.
4 Apr 2011:
Yate 3.3 released.
Support for GMail chat conference, fixes for internal microphone in MacOS. Minor fixes in SS7 M2PA and ANSI. Fixes in H.323, SIP and RTP.

9 Mar 2011:
Yate 3.2 released.
Bug fixes in SIGTRAN/MGCP/SS7 and added support for CNAM/LNP lookup by SIP INVITE/3xx.

Feb 2011:
Yate will attend FOSDEM and XMPP summit.

31 Jan 2011:
Yate 3.1 released.
Yate client support for Google Voice. Support for any country tones in tonegen.

20 Dec 2010:
Yate 3.0 released.
SS7 ITU certified. SS7 STP added. Client supports Jabber IM (Google Talk + Facebook).

3 May 2010:
Yate 3.0.0 alpha 3 released. Featuring the new Jabber server and wideband audio.

8 March 2010:
Yate 2.2 released. Mostly bug fixes. Dahdi compatible. Latest 2 release before 3.0.

6-7 February 2010:
Yate booth at FOSDEM 2010. Free CD with Freesentral available.

2 Nov 2009:
Yate 2.1 launched. Can replace a Cisco PGW2200 to control a Cisco AS54xx.

6 Aug 2008:
Yate and OpenSIPS (former OpenSER) join to build IP based clusters.

4 Aug 2008:
Yate 2 launched.


EditHistoryBacklinksRecent ChangesSearch