[Freeswitch-users] FreeSWITCH, mod_managed and IApiPlugin
Kris
kris at livecall.com
Sun May 8 22:02:17 MSD 2011
You can launch a separate thread...using delegate void Listener();
I haven't done outcalling yet, but my guess is to create a new Session, do
the bridge...and transfer the session to the extension(could start the
bridge here too) that launches the App with the script to play in it's own
thread.
If you get it going, could you send me some of that code...?
Kris
public class Loading : FreeSWITCH.ILoadNotificationPlugin
{
delegate void Listener();
public Loading()
{
Thread currentThread = Thread.CurrentThread;
string threadName = "Thread Loading ";
currentThread.Name = threadName;
Event loading_event = new Event("CUSTOM", "livematch::maintenance");
loading_event.AddHeader("Action", "LiveMatchLoading");
loading_event.Fire();
Log.WriteLine(LogLevel.Info, "Loading constructor. ");
freeswitch.msleep(200);
}
public bool Load()
{
Log.WriteLine(LogLevel.Info, "Load() called.");
ManagedApplicationBase.LoadSystemSettings(); //from the Database
// EventConsumers EventsLivematch = new EventConsumers(10);//<<< INCREASE to
add more events
ManagedApplicationBase.EventsLivematch.Add("CUSTOM",
"livematch::maintenance");
ManagedApplicationBase.EventsLivematch.Add("HEARTBEAT", "");
ManagedApplicationBase.EventsLivematch.Add("CHANNEL_HANGUP", "");
ManagedApplicationBase.EventsLivematch.Add("SHUTDOWN", "");
// ManagedApplicationBase.EventsLivematch.Add("DTMF", "");
new
Listener(ManagedApplicationBase.LiveMatchMaintenanceEvents).BeginInvoke(null,
null);
//subscribe to events
// EventConsumers EventsConference = new EventConsumers(4);//<<< INCREASE to
add more events
ManagedApplicationBase.EventsConference.Add("CUSTOM",
"conference::maintenance");
ManagedApplicationBase.EventsConference.Add("CUSTOM",
"livematch::maintenance"); //to catch loading event so we can exit loop
// ManagedApplicationBase.EventsConference.Add("CUSTOM",
"multicast::event");
ManagedApplicationBase.EventsConference.Add("SHUTDOWN", "");
new
Listener(ManagedApplicationBase.ConferenceMaintenanceEvents).BeginInvoke(null,
null);
Log.WriteLine(LogLevel.Info, "Load() ending.");
return true;
}
}
public static void ConferenceMaintenanceEvents()//runs only in the new
thread
{
Thread.CurrentThread.Name = "Thread ConferenceMaintenanceEvents";
BaseLog.WriteLine(BaseLogLevel.Info, "Starting
ConferenceMaintenanceEvents");
string EventName;
string SessionUUID;
FreeSWITCH.Native.Api fsApi = new FreeSWITCH.Native.Api();
string DigitPressedByMember;
string xml_list = fsApi.Execute("conference", "xml_list");
BaseLog.WriteLine(BaseLogLevel.Info, "Conferences:" + xml_list);
while (!ShuttingDown&&!FreeSwitchShutdown && !LoadingNewDLL)
{
//do DB lookups, outcall here
using (Event ev_all = EventsConference.Pop())
{
if (ev_all != null)
{
}
}
}
----- Original Message -----
From: "Michael Giagnocavo" <mgg at giagnocavo.net>
To: "FreeSWITCH Users Help" <freeswitch-users at lists.freeswitch.org>
Sent: Sunday, May 08, 2011 9:40 AM
Subject: Re: [Freeswitch-users] FreeSWITCH, mod_managed and IApiPlugin
ILoadNotificationPlugin is probably what you want, as it'll get notified
that the assembly is being initialized for FS.
I think you're right about creating new ManagedSession objects, but I don't
recall exactly at this moment.
-Michael
From: freeswitch-users-bounces at lists.freeswitch.org
[mailto:freeswitch-users-bounces at lists.freeswitch.org] On Behalf Of Schenk,
Oliver
Sent: Monday, May 02, 2011 10:03 PM
To: freeswitch-users at lists.freeswitch.org
Subject: [Freeswitch-users] FreeSWITCH, mod_managed and IApiPlugin
Hi All,
I'm completely new to FreeSWITCH, but in a week I managed to achieve quite a
bit. It was quite a learning curve to say the least. This is my current
setup:
- FreeSWITCH 1.0.7 built from tarball.
- Developing on Windows XP with VS2008 in C#.
- Configured extension 1024 to connect to a managed dll file, which
implements IAppPlugin.
- Using X-Lite softphone I can connect to FreeSWITCH as user 1001
and dial 1024 and start going through a menu that I built in C#. It
successfully retrieves records from an SQL database and so forth. No
problems there.
My first step was to create a module that gets called whenever a user dials
IN bound. They will hear the menu just described.
My struggle now is relating to OUT bound calls. What I want is a module that
is started as soon as FreeSWITCH is started and begins executing on an
endless processing loop in the background. This will continuously monitor a
database and if certain conditions occur an outbound call should be queued
and then made. If multiple calls need to be made I guess they will be queued
and processed one by one. I can handle the queuing part.
At this stage I will be testing using extension 1001 as the receiver of the
call using my softphone.
Question 1:
I've been trying to use a class that implements IApiPlugin, but how do I get
it to start when FreeSWITCH starts? As I said it should simply be a never
ending thread as long as FreeSWITCH is running. I can't find any information
regarding how to "Execute" a managed module immediately when FreeSWITCH has
started.
Question 2:
If IApiPlugin can do this, how do I get the session object? Like this?
ManagedSession session = new ManagedSession();
session.Originate(???);
I can't find any help at all on this.
Thanks very much!
Oliver Schenk
NOTICE - This e-mail and any files transmitted with it are confidential and
are only for the use of the person to whom they are addressed.
If you are not the intended recipient then you have received this e-mail in
error; please advise us immediately if this is the case.
Any views expressed in this message are those of the individual sender,
except where the sender specifically states them to be the views of WestNet
Rail.
More information about the FreeSWITCH-users
mailing list