mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-02-08 08:51:50 +00:00
Tweak input/error handling
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9831 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
4b05084f78
commit
e381da0e15
@ -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
|
|||||||
{
|
{
|
||||||
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
|
|||||||
}
|
}
|
||||||
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,35 +85,36 @@ namespace FreeSWITCH.Native
|
|||||||
|
|
||||||
string inputCallback(IntPtr input, Native.switch_input_type_t inputType)
|
string inputCallback(IntPtr input, Native.switch_input_type_t inputType)
|
||||||
{
|
{
|
||||||
switch (inputType) {
|
try {
|
||||||
case FreeSWITCH.Native.switch_input_type_t.SWITCH_INPUT_TYPE_DTMF:
|
switch (inputType) {
|
||||||
using (var dtmf = new Native.switch_dtmf_t(input, false)) {
|
case FreeSWITCH.Native.switch_input_type_t.SWITCH_INPUT_TYPE_DTMF:
|
||||||
return dtmfCallback(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)) {
|
case FreeSWITCH.Native.switch_input_type_t.SWITCH_INPUT_TYPE_EVENT:
|
||||||
return eventCallback(swevt);
|
using (var swevt = new Native.switch_event(input, false)) {
|
||||||
}
|
return eventCallback(swevt);
|
||||||
default:
|
}
|
||||||
return "";
|
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;
|
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 {
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user