提交 e381da0e authored 作者: Michael Giagnocavo's avatar Michael Giagnocavo

Tweak input/error handling

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9831 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 4b05084f
...@@ -57,6 +57,14 @@ namespace FreeSWITCH ...@@ -57,6 +57,14 @@ namespace FreeSWITCH
return false; return false;
} }
AppDomain.CurrentDomain.AssemblyResolve += (_, rargs) => {
Log.WriteLine(LogLevel.Debug, "Trying to resolve assembly '{0}'.", rargs.Name);
if (rargs.Name == Assembly.GetExecutingAssembly().FullName) return Assembly.GetExecutingAssembly();
var path = Path.Combine(managedDir, rargs.Name + ".dll");
Log.WriteLine(LogLevel.Debug, "Resolving to: '" + path + "'.");
return File.Exists(path) ? Assembly.LoadFile(path) : null;
};
// This is a simple one-time loader to get things in memory // This is a simple one-time loader to get things in memory
// Some day we should allow reloading of modules or something // Some day we should allow reloading of modules or something
loadAssemblies(managedDir) loadAssemblies(managedDir)
...@@ -109,6 +117,7 @@ namespace FreeSWITCH ...@@ -109,6 +117,7 @@ namespace FreeSWITCH
{ {
string f = Path.Combine(managedDir, s); string f = Path.Combine(managedDir, s);
try { try {
Log.WriteLine(LogLevel.Debug, "Loading '{0}'.", f);
System.Reflection.Assembly.LoadFile(f); System.Reflection.Assembly.LoadFile(f);
} }
catch (Exception ex) { catch (Exception ex) {
......
...@@ -76,7 +76,6 @@ namespace FreeSWITCH.Native ...@@ -76,7 +76,6 @@ namespace FreeSWITCH.Native
} }
catch (Exception ex) { catch (Exception ex) {
Log.WriteLine(LogLevel.Warning, "Exception in hangupCallback: {0}", ex.ToString()); Log.WriteLine(LogLevel.Warning, "Exception in hangupCallback: {0}", ex.ToString());
throw;
} }
} }
...@@ -86,6 +85,7 @@ namespace FreeSWITCH.Native ...@@ -86,6 +85,7 @@ namespace FreeSWITCH.Native
string inputCallback(IntPtr input, Native.switch_input_type_t inputType) string inputCallback(IntPtr input, Native.switch_input_type_t inputType)
{ {
try {
switch (inputType) { switch (inputType) {
case FreeSWITCH.Native.switch_input_type_t.SWITCH_INPUT_TYPE_DTMF: case FreeSWITCH.Native.switch_input_type_t.SWITCH_INPUT_TYPE_DTMF:
using (var dtmf = new Native.switch_dtmf_t(input, false)) { using (var dtmf = new Native.switch_dtmf_t(input, false)) {
...@@ -98,23 +98,23 @@ namespace FreeSWITCH.Native ...@@ -98,23 +98,23 @@ namespace FreeSWITCH.Native
default: default:
return ""; return "";
} }
} catch (Exception ex) {
Log.WriteLine(LogLevel.Error, "InputCallback threw exception: " + ex.ToString());
return "-ERR InputCallback Exception: " + ex.Message;
}
} }
string dtmfCallback(Native.switch_dtmf_t dtmf) string dtmfCallback(Native.switch_dtmf_t dtmf) {
{
var f = DtmfReceivedFunction; var f = DtmfReceivedFunction;
return f == null ? return f == null ? ""
"-ERR No DtmfReceivedFunction set." : : f(((char)(byte)dtmf.digit), TimeSpan.FromMilliseconds(dtmf.duration));
f(((char)(byte)dtmf.digit), TimeSpan.FromMilliseconds(dtmf.duration));
} }
string eventCallback(Native.switch_event swevt) string eventCallback(Native.switch_event swevt) {
{
using (var evt = new FreeSWITCH.Native.Event(swevt, 0)) { using (var evt = new FreeSWITCH.Native.Event(swevt, 0)) {
var f = EventReceivedFunction; var f = EventReceivedFunction;
return f == null ? return f == null ? ""
"-ERR No EventReceivedFunction set." : : f(evt);
f(evt);
} }
} }
......
...@@ -2758,7 +2758,7 @@ public class freeswitch { ...@@ -2758,7 +2758,7 @@ public class freeswitch {
return ret; return ret;
} }
public static switch_status_t switch_ivr_detect_speech(SWIGTYPE_p_switch_core_session session, string mod_name, string grammar, string path, string dest, switch_asr_handle ah) { public static switch_status_t oh(SWIGTYPE_p_switch_core_session session, string mod_name, string grammar, string path, string dest, switch_asr_handle ah) {
switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_detect_speech(SWIGTYPE_p_switch_core_session.getCPtr(session), mod_name, grammar, path, dest, switch_asr_handle.getCPtr(ah)); switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_detect_speech(SWIGTYPE_p_switch_core_session.getCPtr(session), mod_name, grammar, path, dest, switch_asr_handle.getCPtr(ah));
return ret; return ret;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论