yaypm.utils.outgoing works with forks now

git-svn-id: http://voip.null.ro/svn/yate@3052 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
maciej 2010-02-01 13:29:19 +00:00
parent 6eb57b13ca
commit deafaa3d61
2 changed files with 22 additions and 9 deletions

View File

@ -827,7 +827,7 @@ class TCPDispatcher(Dispatcher, LineReceiver):
"""
Message handler install response parser.
"""
values = values.split(':')
mid = "install-" + values[1]
if self.waiting.has_key(mid):

View File

@ -237,13 +237,26 @@ def outgoing(yate, target, maxcall = 30*1000,
if not (yield execute.dispatch()):
raise OutgoingCallException(formatReason(execute))
end = yate.onwatch("chan.hangup",
lambda m : m["id"] == execute["targetid"],
until = until)
if execute["targetid"].startswith("fork/"):
end = XOR(yate.onwatch("chan.disconnected",
lambda m : m["id"] == execute["id"] and m["answered"] == "false",
until = until),
yate.onwatch("chan.hangup",
lambda m : m["id"] == execute["id"] and m["answered"] == "false",
until = until),
yate.onwatch("chan.hangup",
lambda m : m["targetid"] and m["targetid"].startswith(execute["targetid"]) and m['answered'] == 'true',
until = until))
end.addBoth(lambda r: r[1])
else:
end = yate.onwatch("chan.hangup",
lambda m : m["id"] == execute["targetid"],
until = until)
answered = yate.onwatch(
"call.answered",
lambda m : m["id"] == execute["targetid"],
lambda m : m["targetid"] == execute["id"],
until = end)
def trapAbandoned(f):
@ -254,7 +267,7 @@ def outgoing(yate, target, maxcall = 30*1000,
if logger.isEnabledFor(logging.DEBUG):
def logAnswered(msg):
logger.debug("Answered: %s, %s", execute["id"], execute["targetid"])
logger.debug("Answered: %s, %s", answered["id"], answered["targetid"])
return msg
if retCallIdFast:
@ -265,9 +278,9 @@ def outgoing(yate, target, maxcall = 30*1000,
logger.debug(
"Waiting for answer: %s, %s", execute["targetid"], execute["id"])
yield answered
answered = yield answered
defer.returnValue((execute["id"], execute["targetid"], end))
defer.returnValue((answered["targetid"], answered["id"], end))
## @defer.inlineCallbacks