[Freeswitch-users] C# Example

James Martelletti james at nerdc0re.com
Sun Sep 17 00:16:43 EDT 2006


This is an example of a FreeSwitch module I developed in C# while  
testing (before some IVR commands existed that would help make this  
example smaller). More info will be on its way within a few days.

using System;
using System.Text;
using Freeswitch;
using Freeswitch.Modules;
using Freeswitch.Types;

namespace ModBridgecall
{
     public class ModBridgecall : Module
     {
         public ModBridgecall()
         {
             Name = "dotnetbridgecall";

             AddApplicationInterface(new BridgeApplication());

	    Register();
         }

     }

     public class BridgeApplication : Application
     {
         public BridgeApplication()
         {
             Name                = "dotnetbridge";
             Syntax              = "dotnetbridge blah";
             ShortDescription    = "short description";
             LongDescription     = "long description, long  
description, long description";
             ApplicationFunction = new ApplicationFunction 
(BridgeApplicationFunction);
         }

         public void BridgeApplicationFunction(CoreSession  
coreSession, string data)
         {
             CoreSession   peerSession;
             Channel       callerChannel = coreSession.Channel;
             CallerProfile callerProfile;
             CallerProfile callerCallerProfile =  
callerChannel.CallerProfile;

             string chanType = "iax";
             string chanData = "guest at bleh.com/ext";
             uint   timelimit = 60;

             try
             {
                 callerProfile = new CallerProfile(coreSession,  
callerCallerProfile.Dialplan, callerCallerProfile.CallerIdName,
                                                    
callerCallerProfile.CallerIdNumber,  
callerCallerProfile.NetworkAddress, "ani",
                                                   "ani2", chanData,  
"source", "destionation");

                 peerSession = coreSession.OutgoingChannel(chanType,  
callerProfile);
             }
             catch (Exception e)
             {
                 callerChannel.Hangup();
                 return;
             }

             Ivr.MultiThreadedBridge(coreSession, peerSession,  
timelimit);
         }
     }
}




More information about the Freeswitch-users mailing list