de-oops demo
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10119 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
67015251ad
commit
9bc126b083
|
@ -36,68 +36,45 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace FreeSWITCH.Demo
|
namespace FreeSWITCH.Demo {
|
||||||
{
|
public class AppDemo : AppFunction {
|
||||||
public class AppDemo : AppFunction
|
new protected static bool Load() {
|
||||||
{
|
|
||||||
new protected static bool Load()
|
|
||||||
{
|
|
||||||
Log.WriteLine(LogLevel.Info, "Inside AppDemo::Load.");
|
Log.WriteLine(LogLevel.Info, "Inside AppDemo::Load.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Run() {
|
protected override void Run() {
|
||||||
bool isRecording = false;
|
Session.Answer();
|
||||||
Session.DtmfReceivedFunction = (d, t) => {
|
Session.DtmfReceivedFunction = (d, t) => {
|
||||||
Log.WriteLine(LogLevel.Critical, "RECORDING is {0}", Session.GetVariable("RECORDING"));
|
|
||||||
Log.WriteLine(LogLevel.Info, "Received {0} for {1}.", d, t);
|
Log.WriteLine(LogLevel.Info, "Received {0} for {1}.", d, t);
|
||||||
|
return "";
|
||||||
if (isRecording) {
|
|
||||||
Log.WriteLine(LogLevel.Info, "Recording: [TRUE] Returning crap");
|
|
||||||
return "1";
|
|
||||||
} else {
|
|
||||||
Log.WriteLine(LogLevel.Info, "Recording: [FALSE] Returning null");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
Session.StreamFile(@"C:\freeswitch\Debug\sounds\en\us\callie\voicemail\8000\vm-hello.wav", 0);
|
Log.WriteLine(LogLevel.Info, "Inside AppDemo.Run (args '{0}'); HookState is {1}. Now will collect digits.", Arguments, Session.HookState);
|
||||||
var fn = @"C:\" + Session.GetHashCode() + ".wav";
|
Session.CollectDigits(5000); // Hanging up here will cause an abort and the next line won't be written
|
||||||
isRecording = true;
|
Log.WriteLine(LogLevel.Info, "AppDemo is finishing its run and will now hang up.");
|
||||||
Session.SetVariable("RECORDING", "true");
|
Session.Hangup("USER_BUSY");
|
||||||
Session.RecordFile(fn, 600, 500, 3);
|
|
||||||
isRecording = false;
|
|
||||||
Session.SetVariable("RECORDING", "false");
|
|
||||||
Session.sleep(500);
|
|
||||||
Log.WriteLine(LogLevel.Info, "WW GROUP: Finished Recording file");
|
|
||||||
var res = Session.PlayAndGetDigits(1, 1, 3, 3000, "*", @"C:\freeswitch\libs\sounds\en\us\callie\ivr\8000\ivr-sample_submenu.wav", @"C:\freeswitch\libs\sounds\en\us\callie\ivr\8000\ivr-sample_submenu.wav", "1|2|3|9|#");
|
|
||||||
Log.WriteLine(LogLevel.Info, "WW GROUP: Message Menu [" + res + "]");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void hangupHook()
|
void hangupHook() {
|
||||||
{
|
|
||||||
Log.WriteLine(LogLevel.Debug, "AppDemo hanging up, UUID: {0}.", this.Uuid);
|
Log.WriteLine(LogLevel.Debug, "AppDemo hanging up, UUID: {0}.", this.Uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool AbortOnHangup { get { return true; } }
|
protected override bool AbortOnHangup { get { return true; } }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ApiDemo : ApiFunction
|
public class ApiDemo : ApiFunction {
|
||||||
{
|
new protected static bool Load() {
|
||||||
new protected static bool Load()
|
|
||||||
{
|
|
||||||
Log.WriteLine(LogLevel.Debug, "Inside ApiDemo::Load.");
|
Log.WriteLine(LogLevel.Debug, "Inside ApiDemo::Load.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ExecuteBackground(string args)
|
public override void ExecuteBackground(string args) {
|
||||||
{
|
|
||||||
Log.WriteLine(LogLevel.Debug, "ApiDemo on a background thread #({0}), with args '{1}'.",
|
Log.WriteLine(LogLevel.Debug, "ApiDemo on a background thread #({0}), with args '{1}'.",
|
||||||
System.Threading.Thread.CurrentThread.ManagedThreadId,
|
System.Threading.Thread.CurrentThread.ManagedThreadId,
|
||||||
args);
|
args);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Execute(Native.Stream stream, Native.Event evt, string args)
|
public override void Execute(Native.Stream stream, Native.Event evt, string args) {
|
||||||
{
|
|
||||||
stream.Write(string.Format("ApiDemo executed with args '{0}' and event type {1}.",
|
stream.Write(string.Format("ApiDemo executed with args '{0}' and event type {1}.",
|
||||||
args, evt == null ? "<none>" : evt.GetEventType()));
|
args, evt == null ? "<none>" : evt.GetEventType()));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue