我正在做一些电子邮件到传真网关—一些python程序将使得Asterisk 调用文件,并把它们放入一些队列(基于文件或数据库)。
然后,另一个程序应该从队列中“调用任务”,并将它们“喂”给星号(由于res_fax_digium将放弃限制过多的任务,因此要遵守一些configuration的限制)。
接下来,让我们假设,一切都很好,星号成功地发送了一些传真文件。 有什么办法可以获得这种手术的状态?
如果日志文件parsing是最好的,我可能会分配一些特殊的accountcode (我可以玩这个字段,也许)将CDR分成不同的文件。
请问,我应该评估哪些其他方式?
所以,我放弃了这种做法,并将采取另一种方式— AMI,Asterisk Management Interface API。
用几句话说。
创build像这样的拨号计划:
[01-sendfax] exten => _X.,1,NoOp() same => n,SendFax(${faxfile},f)
我可以发起呼叫(使用pyst ):
res = mgr.originate( 'SIP/m2000/1234567', '1234567', context='01-sendfax', priority='1', caller_id='7654321', async=True, variables={ 'TRUNK': 'SIP/m2000', 'faxfile': '/tmp/file.tiff', } )
并且在manager.conf中设置了debug = on ,我可以听到所需的事件:
# will catch a status of `originate` call # (this does not require `debug = on` in `manager.conf`): mgr.register_event('OriginateResponse', handle_response) # will catch `SendFax` application's result: mgr.register_event('FaxStatus', handle_response)
所以,在res_fax_digium完成后, res_fax_digium会触发FaxStatus事件。