📄 0088.htm
字号:
<html>
<head>
<title>新时代软件教程:操作系统 主页制作 服务器 设计软件 网络技术 编程语言 文字编辑</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style>
<!--
body, table {font-size: 9pt; font-family: 宋体}
a {text-decoration:none}
a:hover {color: red;text-decoration:underline}
.1 {background-color: rgb(245,245,245)}
-->
</style>
</head>
<p align="center"><script src="../../1.js"></script></a>
<p align="center"><big><strong>八、参考资料</strong></big></p>
<div align="right">---(文/吴宗锡)</div>
<A
name=eight>八、参考资料</A>
<DL>
<DT>
<DD><A name=1>[1]</A> JTAPI specification version 1.2 on <A
href="../../www.javasoft.com/products/jtapi/index.html">http://www.javasoft.com/products/jtapi/index.html</A>
<DD><A name=2>[2]</A> JTAPI slids on JavaOne <A
href="../../www.javasoft.com/javaone/javaone98/sessionsTOCs/T603.html">http://www.javasoft.com/javaone/javaone98/sessionsTOCs/T603.html</A></DD></DL><BR><BR><BR><A
name=p1><B>程式一 Call Observer</B> <BR>
<P align=center>
<TABLE width="70%">
<TBODY>
<TR>
<TD class=detail><PRE>
import javax.telephony.*;
import javax.telephony.events.*;
/*
*MyOutCallObserver class implements CallObserver
* interface1并且接收与Call相关的events
*/
public class MyOutCallObserver implements CallObserver {
public void callChangedEvent(CallEv[] evlist)
{
for (int i = 0; i < evlist.length; i++) {
if (evlist[i] instanceof ConnEv) {
String name = null;
try {
Connection connection = ((ConnEv)evlist[i]).getConnection();
Address addr = connection.getAddress();
name = addr.getName();
} catch (Exception excp) {
// Handle Exceptions
}
String msg = "Connection to Address: " + name + " is ";
if (evlist[i].getID() == ConnAlertingEv.ID) {
System.out.println(msg + "ALERTING");
}
else if (evlist[i].getID() == ConnInProgressEv.ID) {
System.out.println(msg + "INPROGRESS");
}
else if (evlist[i].getID() == ConnConnectedEv.ID) {
System.out.println(msg + "CONNECTED");
}
else if (evlist[i].getID() == ConnDisconnectedEv.ID) {
System.out.println(msg + "DISCONNECTED");
}
}
}
}
}
</PRE></TD></TR></TBODY></TABLE></P><PRE></PRE><BR><BR><BR><A name=p2><B>程式二 main program</B> <BR>
<P align=center>
<TABLE width="70%">
<TBODY>
<TR>
<TD class=detail><PRE>import javax.telephony.*;
import javax.telephony.events.*;
import MyOutCallObserver;
/*
*由自己的电话号码476111打到 号码5551212
*/
public class Outcall {
public static final void main(String args[]) {
/**事先取得default JTAPI的implementation(JtapiPeer),
*并且藉由之产生default Provider
*/
Provider myprovider = null;
try {
JtapiPeer peer = JtapiPeerFactory.getJtapiPeer(null);
myprovider = peer.getProvider(null);
} catch (Exception excp) {
System.out.println("Can't get Provider: " + excp.toString());
System.exit(0);
}
// 取得我端电话相关的objects(Address及相符之Terminal)
Address origaddr = null;
Terminal origterm = null;
try {
origaddr = myprovider.getAddress("4761111");
/* 取一此电话号码相对应的Terminal */
Terminal[] terminals = origaddr.getTerminals();
if (terminals == null) {
System.out.println("No Terminals on Address.");
System.exit(0);
}
origterm = terminals[0];
} catch (Exception excp) {
// Handle exceptions;
}
// Create telephone call object并且加入 observer侦测state
Call mycall = null;
try {
mycall = myprovider.createCall();
mycall.addObserver(new MyOutCallObserver());
} catch (Exception excp) {
// Handle exceptions
}
//Place the telephone call.
try {
Connection c[] = mycall.connect(origterm, origaddr, "5551212");
} catch (Exception excp) {
// Handle all Exceptions
}
}
}
</PRE></TD></TR></TBODY></TABLE></P>
</table>
<p align="center"><script src="../../2.js"></script></a>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -