Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Disconnecting TAPI Call through C#.net code

401 views
Skip to first unread message

RK

unread,
Oct 24, 2006, 6:05:03 PM10/24/06
to
I have made a web application which will get the phone number from a html
page and will dial that number. I have a button on this web project called
"Disconnect" which when clicked on will disconnect the call. Somehow the
Disconnect function is not working properly. We are using CISCO Tapi Client.
Below is the code I am using:-
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Runtime.InteropServices;

using TAPI3Lib;

namespace Tapi_App1
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.TextBox textBox2;
protected System.Web.UI.WebControls.Button button6;
protected System.Web.UI.WebControls.Button button5;
protected System.Web.UI.WebControls.Button Button3;
protected System.Web.UI.WebControls.Button Button4;
protected System.Web.UI.WebControls.Button button2;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.DropDownList comboBox1;
protected System.Web.UI.WebControls.CheckBox checkBox2;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.TextBox textBox1;
protected System.Web.UI.WebControls.CheckBox checkBox1;

private TAPIClass tobj;
public ITAddress[] ia=new TAPI3Lib.ITAddress[10];
private ITBasicCallControl bcc;
private callnotification cn;
private bool h323,reject;
uint lines;
int line;
int[] registertoken=new int[10];

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if(!(IsPostBack))
{
string strContactNo;
//strContactNo = Request.QueryString["ContactNo"];
strContactNo = "***********";
callContact(strContactNo);
}
}

public void callContact(string strContactNo)
{
initializetapi3();
h323=true;
reject=true;

registertoken[line] =
tobj.RegisterCallNotifications(ia[0],true,true,TapiConstants.TAPIMEDIATYPE_AUDIO,2);

TAPI3Lib.ITAddress ln=null;
ln=ia[line];
if(strContactNo.Length!=0)
{
try
{
if(!h323)
{
bcc =
ln.CreateCall(strContactNo,TapiConstants.LINEADDRESSTYPE_PHONENUMBER|TapiConstants.LINEADDRESSTYPE_IPADDRESS,TapiConstants.TAPIMEDIATYPE_DATAMODEM|TapiConstants.TAPIMEDIATYPE_AUDIO);
bcc.SetQOS(TapiConstants.TAPIMEDIATYPE_DATAMODEM|TapiConstants.TAPIMEDIATYPE_AUDIO,QOS_SERVICE_LEVEL.QSL_BEST_EFFORT);
bcc.Connect(false);
}
else
{
bcc =
ln.CreateCall(strContactNo,TapiConstants.LINEADDRESSTYPE_IPADDRESS,TapiConstants.TAPIMEDIATYPE_AUDIO);
bcc.Connect(false);
}
}
catch(Exception exp)
{
Response.Write("Failed to create call!");
tobj.Shutdown();
}
}
else
{
Response.Write("Please enter number to dial.. ");
tobj.Shutdown();
}
}

void initializetapi3()
{
try
{
tobj = new TAPIClass();
tobj.Initialize();
IEnumAddress ea=tobj.EnumerateAddresses();
ITAddress ln;
uint arg3=0;
lines=0;

tobj.ITTAPIEventNotification_Event_Event+= new
TAPI3Lib.ITTAPIEventNotification_EventEventHandler(cn.Event);
tobj.EventFilter=(int)(TAPI_EVENT.TE_CALLNOTIFICATION|
TAPI_EVENT.TE_DIGITEVENT|
TAPI_EVENT.TE_PHONEEVENT|
TAPI_EVENT.TE_CALLSTATE|
TAPI_EVENT.TE_GENERATEEVENT|
TAPI_EVENT.TE_GATHERDIGITS|
TAPI_EVENT.TE_REQUEST);

for(int i=0;i<10;i++)
{
ea.Next(1,out ln,ref arg3);
ia[i]=ln;
if(ln!=null)
{
comboBox1.Items.Add(ia[i].AddressName);
if (!(ln.AddressName.IndexOf("Cisco").Equals(-1)))
{
ia[0] = ln;
break;
}
lines++;
}
else
break;
}
}
catch(Exception e)
{
Response.Write(e.ToString());
}
}

private void Button4_Click(object sender, System.EventArgs e)
{
IEnumCall ec = ia[line].EnumerateCalls();
uint arg = 0;
ITCallInfo ici;
try
{
ec.Next(1,out ici,ref arg);
ITBasicCallControl bc=(ITBasicCallControl)ici;
bcc.Disconnect(DISCONNECT_CODE.DC_NORMAL);
ici.ReleaseUserUserInfo();
}
catch(Exception exp)
{
Response.Write("No call to disconnect!");
}
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Button4.Click += new System.EventHandler(this.Button4_Click);
//this.button2.Click += new System.EventHandler(this.button2_Click);
this.comboBox1.SelectedIndexChanged += new
System.EventHandler(this.comboBox1_SelectedIndexChanged);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion

private void comboBox1_SelectedIndexChanged(object sender,
System.EventArgs e)
{
line=comboBox1.SelectedIndex;
}
}

class callnotification:TAPI3Lib.ITTAPIEventNotification
{
public delegate void listshow(string str);
public listshow addtolist;

public void Event(TAPI3Lib.TAPI_EVENT te,object eobj)
{
switch(te)
{
case TAPI3Lib.TAPI_EVENT.TE_CALLNOTIFICATION:
addtolist("call notification event has occured");
break;
case TAPI3Lib.TAPI_EVENT.TE_DIGITEVENT:
TAPI3Lib.ITDigitDetectionEvent dd=(TAPI3Lib.ITDigitDetectionEvent)eobj;
addtolist("Dialed digit"+dd.ToString());
break;
case TAPI3Lib.TAPI_EVENT.TE_GENERATEEVENT:
TAPI3Lib.ITDigitGenerationEvent dg=(TAPI3Lib.ITDigitGenerationEvent)eobj;
addtolist("Dialed digit"+dg.ToString());
break;
case TAPI3Lib.TAPI_EVENT.TE_PHONEEVENT:
addtolist("A phone event!");
break;
case TAPI3Lib.TAPI_EVENT.TE_GATHERDIGITS:
addtolist("Gather digit event!");
break;
case TAPI3Lib.TAPI_EVENT.TE_CALLSTATE:
TAPI3Lib.ITCallStateEvent a=(TAPI3Lib.ITCallStateEvent)eobj;
TAPI3Lib.ITCallInfo b=a.Call;
switch(b.CallState)
{
case TAPI3Lib.CALL_STATE.CS_INPROGRESS:
addtolist("dialing");
break;
case TAPI3Lib.CALL_STATE.CS_CONNECTED:
addtolist("Connected");
break;
case TAPI3Lib.CALL_STATE.CS_DISCONNECTED:
addtolist("Disconnected");
break;
case TAPI3Lib.CALL_STATE.CS_OFFERING:
addtolist("A party wants to communicate with you!");
break;
case TAPI3Lib.CALL_STATE.CS_IDLE:
addtolist("Call is created!");
break;
}
break;
}
}
}
}

Andreas Marschall [MVP TAPI]

unread,
Oct 25, 2006, 4:12:24 AM10/25/06
to
"RK" <R...@discussions.microsoft.com> schrieb im Newsbeitrag
news:2C82669C-D117-47D0...@microsoft.com...

> I have made a web application which will get the phone number from a html
> page and will dial that number. I have a button on this web project called
> "Disconnect" which when clicked on will disconnect the call. Somehow the
> Disconnect function is not working properly. We are using CISCO Tapi Client.

RK,
Regarding TAPI and .NET see KB article "841712 - Telephony Application
Programming Interface (TAPI) functionality is not supported from managed
code".
See my TAPI and TSPI FAQ:
Q: Are there any .NET wrappers for TAPI2 available ?
http://www.i-b-a-m.de/Andreas_Marschall's_TAPI_and_TSPI_FAQ.htm#_Q:_Are_there_4

You may want to take a look at JulMar's
ITAPI3 - TAPI 3.0 wrapper for .NET 2.0
and
TAPI2 ATAPI.NET - TAPI Application class library for .NET 2.0:
http://www.julmar.com/samples.htm
http://www.julmar.com/blog/mark/CategoryView,category,Tapi.aspx

--
Best Regards
Andreas Marschall
Microsoft MVP for TAPI / Windows SDK
TAPI / TSP Developer and Tester
My TAPI and TSPI FAQ:
http://www.I-B-A-M.de/Andreas_Marschall's_TAPI_and_TSPI_FAQ.htm
My Toto® Tools (a collection of free, mostly TAPI related tools):
http://www.i-b-a-m.de/Andreas_Marschall's_Toto_Tools.htm
TAPI development around the world (Frappr! map):
http://www.frappr.com/TAPIaroundTheWorld
* Please post all messages and replies to the newsgroup so all may
* benefit from the discussion. Private mail is usually not replied to.
* This posting is provided "AS IS" with no warranties, and confers no rights.


RK

unread,
Oct 25, 2006, 12:04:02 PM10/25/06
to
Thank You Andreas for the quick reply.
I looked at the code for ITAPI3 - "TAPI 3.0 wrapper for .NET 2.0" at
http://www.julmar.com/samples.htm.
I was able to run the project and even dial the number from the code (
project OutgoingSample) but it is the same case with this also I am not able
to disconnect the line when I click on disconnect button on the
OutgoingSample\OutgoingForm.cs form.
I have to mannualy end the call from the phone handset. I want that user
should just click on the disconnect button and the call should end.

Help needed ASAP.
Thanks
RK

Grant Schenck

unread,
Oct 26, 2006, 9:05:36 AM10/26/06
to
What happens when you try this from the MS TAPI Browser 3.x?
--
Grant Schenck
http://grantschenck.tripod.com/


"RK" <R...@discussions.microsoft.com> wrote in message
news:487CB9BA-8464-4EEA...@microsoft.com...

RK

unread,
Oct 26, 2006, 10:58:02 AM10/26/06
to
Thanks! but from where can I have MS TAPI Browser 3.x?

Grant Schenck

unread,
Oct 26, 2006, 3:34:35 PM10/26/06
to

RK

unread,
Oct 26, 2006, 5:36:03 PM10/26/06
to
I have downloaded it but I am sorry to ask you thins what I need to do with
this.

Grant Schenck

unread,
Oct 27, 2006, 8:57:12 AM10/27/06
to
You'll have to read the FAQ and review past postings. Good luck.

"RK" <R...@discussions.microsoft.com> wrote in message

news:B34E8054-A21F-4685...@microsoft.com...

Andreas Marschall [MVP TAPI]

unread,
Nov 1, 2006, 7:24:28 AM11/1/06
to
"RK" <R...@discussions.microsoft.com> schrieb im Newsbeitrag
news:B34E8054-A21F-4685...@microsoft.com...

> I have downloaded it but I am sorry to ask you thins what I need to do with
> this.

RK,


See my TAPI and TSPI FAQ:

Q: Is there a user guide available for TAPI Browser TB3x ?
http://www.i-b-a-m.de/Andreas_Marschall's_TAPI_and_TSPI_FAQ.htm#_Q:_Is_there_2

0 new messages