using System.Linq;\r
using System.Text;\r
\r
-namespace FreeSWITCH.Demo\r
-{\r
- public class AppDemo : AppFunction\r
- {\r
- new protected static bool Load()\r
- {\r
+namespace FreeSWITCH.Demo {\r
+ public class AppDemo : AppFunction {\r
+ new protected static bool Load() {\r
Log.WriteLine(LogLevel.Info, "Inside AppDemo::Load.");\r
return true;\r
}\r
\r
protected override void Run() {\r
- bool isRecording = false;\r
+ Session.Answer();\r
Session.DtmfReceivedFunction = (d, t) => {\r
- Log.WriteLine(LogLevel.Critical, "RECORDING is {0}", Session.GetVariable("RECORDING"));\r
Log.WriteLine(LogLevel.Info, "Received {0} for {1}.", d, t);\r
-\r
- if (isRecording) {\r
- Log.WriteLine(LogLevel.Info, "Recording: [TRUE] Returning crap");\r
- return "1";\r
- } else {\r
- Log.WriteLine(LogLevel.Info, "Recording: [FALSE] Returning null");\r
- return null;\r
- }\r
+ return "";\r
};\r
- Session.StreamFile(@"C:\freeswitch\Debug\sounds\en\us\callie\voicemail\8000\vm-hello.wav", 0);\r
- var fn = @"C:\" + Session.GetHashCode() + ".wav";\r
- isRecording = true;\r
- Session.SetVariable("RECORDING", "true");\r
- Session.RecordFile(fn, 600, 500, 3);\r
- isRecording = false;\r
- Session.SetVariable("RECORDING", "false");\r
- Session.sleep(500);\r
- Log.WriteLine(LogLevel.Info, "WW GROUP: Finished Recording file");\r
- 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|#");\r
- Log.WriteLine(LogLevel.Info, "WW GROUP: Message Menu [" + res + "]");\r
+ Log.WriteLine(LogLevel.Info, "Inside AppDemo.Run (args '{0}'); HookState is {1}. Now will collect digits.", Arguments, Session.HookState);\r
+ Session.CollectDigits(5000); // Hanging up here will cause an abort and the next line won't be written\r
+ Log.WriteLine(LogLevel.Info, "AppDemo is finishing its run and will now hang up.");\r
+ Session.Hangup("USER_BUSY");\r
}\r
- \r
- void hangupHook()\r
- {\r
+\r
+ void hangupHook() {\r
Log.WriteLine(LogLevel.Debug, "AppDemo hanging up, UUID: {0}.", this.Uuid);\r
}\r
\r
- protected override bool AbortOnHangup { get { return true; } } \r
+ protected override bool AbortOnHangup { get { return true; } }\r
}\r
\r
- public class ApiDemo : ApiFunction\r
- {\r
- new protected static bool Load()\r
- {\r
+ public class ApiDemo : ApiFunction {\r
+ new protected static bool Load() {\r
Log.WriteLine(LogLevel.Debug, "Inside ApiDemo::Load.");\r
return true;\r
}\r
\r
- public override void ExecuteBackground(string args)\r
- {\r
+ public override void ExecuteBackground(string args) {\r
Log.WriteLine(LogLevel.Debug, "ApiDemo on a background thread #({0}), with args '{1}'.",\r
System.Threading.Thread.CurrentThread.ManagedThreadId,\r
args);\r
}\r
\r
- public override void Execute(Native.Stream stream, Native.Event evt, string args)\r
- {\r
+ public override void Execute(Native.Stream stream, Native.Event evt, string args) {\r
stream.Write(string.Format("ApiDemo executed with args '{0}' and event type {1}.",\r
args, evt == null ? "<none>" : evt.GetEventType()));\r
}\r