]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
de-oops demo
authorMichael Giagnocavo <mgg@giagnocavo.net>
Wed, 22 Oct 2008 22:10:58 +0000 (22:10 +0000)
committerMichael Giagnocavo <mgg@giagnocavo.net>
Wed, 22 Oct 2008 22:10:58 +0000 (22:10 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10119 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/languages/mod_managed/managed/Demo.cs

index 910f678e58eecaebe50f7cc7996f6b203090b34f..9ca04986d99ccb248ee1df3d7aeeee4f423460e4 100644 (file)
@@ -36,68 +36,45 @@ using System.Collections.Generic;
 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