[ previous ] [ next ] [ threads ]
 To :  Atis <atissita@b...>
 From :  Maciek Kaminski <maciejka@t...>
 Subject :  Re: [yate] placing an outgoing call
 Date :  Thu, 22 Feb 2007 10:21:41 +0100
Atis napisał(a):

> ...
> My problem, however, is that I wish to make a call without there being
> an incoming call. Can't figure out how to do this..
> 

Here is sniplet if yaypm script doing outgoing call. You should be able 
to extract message flow from it:


  def outgoing(yate, target, maxcall = 20*1000,
               callto = "dumb/", formats = None, ret_callid = False):

      logger.debug("Calling: %s" % target)

      attrs = {"callto": callto,
               "target": target,
               "maxcall": maxcall}
      if formats:
          attrs["media_audio"] = "yes"
          attrs["formats_audio"] = formats

      execute = yate.msg("call.execute", attrs)
      yield execute.dispatch()

      if not getResult():
          raise Exception("Can't call %s because: \'%s\'" % \
                      (target, execute["reason"]))
      if ret_callid:
          yield execute["targetid"]

      end = yate.onwatch("chan.hangup",
          lambda m : m["id"] == execute["targetid"])

      logger.debug(
          "Waiting for answer: %s, %s" % (execute["id"], 
execute["targetid"]))

      yield yate.onwatch(
          "call.answered",
          lambda m : m["id"] ==  execute["targetid"],
          until = end)

      answered = getResult()
      logger.debug("Answered: %s, %s" % (answered["id"], answered["id"]))

      yield answered

mk