[asterisk-commits] russell: branch russell/bindings r103329 - in /team/russell/bindings/bindings...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Feb 11 17:50:27 CST 2008
Author: russell
Date: Mon Feb 11 17:50:27 2008
New Revision: 103329
URL: http://svn.digium.com/view/asterisk?view=rev&rev=103329
Log:
add ability to read a digit
Modified:
team/russell/bindings/bindings/ast_channel.i
team/russell/bindings/bindings/examples/ast_channel_test.py
Modified: team/russell/bindings/bindings/ast_channel.i
URL: http://svn.digium.com/view/asterisk/team/russell/bindings/bindings/ast_channel.i?view=diff&rev=103329&r1=103328&r2=103329
==============================================================================
--- team/russell/bindings/bindings/ast_channel.i (original)
+++ team/russell/bindings/bindings/ast_channel.i Mon Feb 11 17:50:27 2008
@@ -4,6 +4,7 @@
#include "asterisk.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
+#include "asterisk/app.h"
#include "res_python/res_python.h"
%}
@@ -93,6 +94,8 @@
static __thread char workspace[1024];
char *var_val = NULL;
+ *workspace = '\0';
+
if (var_name[strlen(var_name) - 1] == ')') {
ast_func_read($self, var_name, workspace, sizeof(workspace));
var_val = workspace;
@@ -102,4 +105,16 @@
return var_val;
}
+
+ const char * read_digit(const char *prompt = "silence/1", int timeout = 0)
+ {
+ static __thread char buf[2];
+
+ buf[0] = '\0';
+ buf[1] = '\0';
+
+ ast_app_getdata($self, prompt, buf, 1, timeout);
+
+ return buf;
+ }
};
Modified: team/russell/bindings/bindings/examples/ast_channel_test.py
URL: http://svn.digium.com/view/asterisk/team/russell/bindings/bindings/examples/ast_channel_test.py?view=diff&rev=103329&r1=103328&r2=103329
==============================================================================
--- team/russell/bindings/bindings/examples/ast_channel_test.py (original)
+++ team/russell/bindings/bindings/examples/ast_channel_test.py Mon Feb 11 17:50:27 2008
@@ -3,12 +3,24 @@
def ast_app(chan):
print '(ast_channel test) Channel is ' + chan.get_name() + ', currently executing ' \
+ chan.get_context() + ',' + chan.get_exten() + ',' + repr(chan.get_priority()) + '.'
+
print 'Answering ...'
chan.answer()
+
print 'Executing Playback of tt-weasels ...'
chan.exec_app('Playback', 'tt-weasels')
+
print 'setting FOO to BAR ...'
chan.set_var('FOO', 'BAR')
+
print 'variable FOO is: ' + chan.get_var('FOO')
+
+ print 'playing a beep and then waiting 3 seconds for a digit ...'
+ digit = chan.read_digit('beep', 3000)
+ if len(digit) != 0:
+ print 'Got digit ' + digit
+ else:
+ print 'Did not read a digit'
+
print 'Hanging up ...'
chan.hangup()
More information about the asterisk-commits
mailing list