求教高手,利用c#编写TAPI3的拨打电话程序的事件响应问题,外呼怎么触发不了事件。

somymusic2 2010-08-03 05:06:30
我编写了一个利用TAPI3.0拨打电话的程序,电话可以正常拨通,但是我想获取拨打电话过程中的线路状态(即是否已经拨通),看了不少资料例子都说TAPI有事件响应的,但是我点完呼叫按钮(BUTTON)以后,似乎事件响应函数并没有反应,我想知道在利用CreateCall函数开始拨号以后到底应该产生什么事件(是TE_CALLSTATE吗?),我的textBox1控件中什么内容也没有,应该说明Event函数应该没有被调用,求高手帮助,谢谢。

TAPI注册事件代码:
tc.ITTAPIEventNotification_Event_Event += new ITTAPIEventNotification_EventEventHandler(this.Event); //注册TAPI通知事件
tc.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); //初始化事件过滤器

事件响应部分:
public void Event(TAPI3Lib.TAPI_EVENT te, object eobj)
{
string str = "";
textBox1.AppendText("函数走到这里了");
switch (te)
{
case TAPI3Lib.TAPI_EVENT.TE_DIGITEVENT:
TAPI3Lib.ITDigitDetectionEvent dd = (TAPI3Lib.ITDigitDetectionEvent)eobj;
str = "Dialed digit" + dd.ToString();
textBox1.AppendText(str);
break;
case TAPI3Lib.TAPI_EVENT.TE_GENERATEEVENT:
TAPI3Lib.ITDigitGenerationEvent dg = (TAPI3Lib.ITDigitGenerationEvent)eobj;
str = "Dialed digit" + dg.ToString();
textBox1.AppendText(str);
break;
case TAPI3Lib.TAPI_EVENT.TE_PHONEEVENT:
str = "A phone event!";
textBox1.AppendText(str);
break;
case TAPI3Lib.TAPI_EVENT.TE_GATHERDIGITS:
str = "Gather digit event!";
textBox1.AppendText(str);
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:
str = "dialing";
textBox1.AppendText(str);;
break;
case TAPI3Lib.CALL_STATE.CS_CONNECTED:
str = "Connected";
textBox1.AppendText(str);
break;
case TAPI3Lib.CALL_STATE.CS_DISCONNECTED:
str = "Disconnected";
textBox1.AppendText(str);
break;
case TAPI3Lib.CALL_STATE.CS_OFFERING:
str = "A party wants to communicate with you!";
textBox1.AppendText(str);
break;
case TAPI3Lib.CALL_STATE.CS_IDLE:
str = "Call is created!";
textBox1.AppendText(str);
break;
}
break;
}

拨号部分代码:
private void Dial_Click(object sender, EventArgs e)
{
String number = "13401184611";
bcc = address[currentline].CreateCall(number, TapiConstants.LINEADDRESSTYPE_PHONENUMBER, TapiConstants.TAPIMEDIATYPE_DATAMODEM);
ITCallInfo callInfo = (ITCallInfo)bcc;
bcc.Connect(false);
}
...全文
147 3 打赏 收藏 举报
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
gsbear 2011-02-10
  • 打赏
  • 举报
回复
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;
MessageBox.Show("digit dialed!");
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;
}
}
Mr_Edwin 2010-08-03
  • 打赏
  • 举报
回复
恩,网上有很多这样的问题,去百度,google找找
http://ufo-crackerx.blog.163.com/
crackdung 2010-08-03
  • 打赏
  • 举报
回复
参考这个组件,很好的

网站




my blog
http://ufo-crackerx.blog.163.com/
发帖
C#

10.8w+

社区成员

.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
帖子事件
创建了帖子
2010-08-03 05:06
社区公告

让您成为最强悍的C#开发者