提交 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
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
// Some day we should allow reloading of modules or something
loadAssemblies(managedDir)
......@@ -109,6 +117,7 @@ namespace FreeSWITCH
{
string f = Path.Combine(managedDir, s);
try {
Log.WriteLine(LogLevel.Debug, "Loading '{0}'.", f);
System.Reflection.Assembly.LoadFile(f);
}
catch (Exception ex) {
......
......@@ -76,7 +76,6 @@ namespace FreeSWITCH.Native
}
catch (Exception ex) {
Log.WriteLine(LogLevel.Warning, "Exception in hangupCallback: {0}", ex.ToString());
throw;
}
}
......@@ -86,35 +85,36 @@ namespace FreeSWITCH.Native
string inputCallback(IntPtr input, Native.switch_input_type_t inputType)
{
switch (inputType) {
case FreeSWITCH.Native.switch_input_type_t.SWITCH_INPUT_TYPE_DTMF:
using (var dtmf = new Native.switch_dtmf_t(input, false)) {
return dtmfCallback(dtmf);
}
case FreeSWITCH.Native.switch_input_type_t.SWITCH_INPUT_TYPE_EVENT:
using (var swevt = new Native.switch_event(input, false)) {
return eventCallback(swevt);
}
default:
return "";
try {
switch (inputType) {
case FreeSWITCH.Native.switch_input_type_t.SWITCH_INPUT_TYPE_DTMF:
using (var dtmf = new Native.switch_dtmf_t(input, false)) {
return dtmfCallback(dtmf);
}
case FreeSWITCH.Native.switch_input_type_t.SWITCH_INPUT_TYPE_EVENT:
using (var swevt = new Native.switch_event(input, false)) {
return eventCallback(swevt);
}
default:
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;
return f == null ?
"-ERR No DtmfReceivedFunction set." :
f(((char)(byte)dtmf.digit), TimeSpan.FromMilliseconds(dtmf.duration));
return f == null ? ""
: 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)) {
var f = EventReceivedFunction;
return f == null ?
"-ERR No EventReceivedFunction set." :
f(evt);
return f == null ? ""
: f(evt);
}
}
......
......@@ -2758,7 +2758,7 @@ public class freeswitch {
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));
return ret;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论