一.工作流程:
客户端发送cer命令去请求连接服务器(OCS),当ocs返回成功的cea命令,则表明与ocs的链接建立成功;
为了保证客户端与服务器连接正常,需每隔一段时间发送dwr命令检测链路;
有了以上的保证,客户端可以放心的发送ccr命令与服务器进行数据交互
二.操作步骤
1.初始化(与ocs连接和心跳响应被jdiameter内部实现,开发者可以不考虑构造和发送cer命令和dwr命令)
init方法:
ClientConfiguration clientConfiguration = new ClientConfiguration();
Stack stack = new org.jdiameter.client.impl.StackImpl();
SessionFactory factory = stack.init(clientConfiguration);
Loggers.FSM.logger().setLevel(Level.ALL);
Loggers.Stack.logger().setLevel(Level.ALL);
ConsoleHandler fh = new ConsoleHandler();
fh.setLevel(Level.ALL);
stack.getLogger().addHandler(fh);
stack.getLogger().setUseParentHandlers(false);
// start(Mode mode, long timeout, java.util.concurrent.TimeUnit
// unit)
stack.start(Mode.ALL_PEERS, stackTimeOut, TimeUnit.SECONDS);
ClientConfiguration类:
public static class ClientConfiguration extends EmptyConfiguration {
public ClientConfiguration() {
super();
log.info("加载配置文件开始");
AppConfiguration appConfiguration = AppConfiguration.getInstance();
add(OwnDiameterURI, "aaa://" + AvpContants.ORIGIN_HOST + ":"
+ appConfiguration.getClientPort());
log.info("OwnDiameterURI:" + "aaa://" + AvpContants.ORIGIN_HOST
+ ":" + appConfiguration.getClientPort());
add(OwnIPAddress, appConfiguration.getClientIp());
add(OwnRealm, hostRealm);
add(OwnVendorID, vendorId);
add(ApplicationId,
// AppId 1
getInstance().add(VendorId, vendorId).add(AcctApplId,
acctApplId));
add(DwaTimeOut, (long) appConfiguration.getAvpDwrTimeout());
// dwr 间隔时间
add(IacTimeOut, (long) appConfiguration.getAvpDwrTimeout());
add(CeaTimeOut, (long) appConfiguration.getAvpCerTimeout());
add(RecTimeOut, (long) appConfiguration.getAvpCerTimeout());
// peerTable 用来管理peer
// 一个Peer对象表示一个远程的Diameter客户端,服务器或者代理。
add(PeerTable,
// Peer 1
getInstance().add(
PeerName,
"aaa://" + appConfiguration.getServerIp() + ":"
+ appConfiguration.getServerPort()));// 连接ip+port
log.info("PeerName___" + "aaa://" + appConfiguration.getServerIp()
+ ":" + appConfiguration.getServerPort());
// realm 域信息
add(RealmTable,
// Realm 1
getInstance().add(
RealmEntry,
hostRealm + ":" + AvpContants.ORIGIN_HOST + ","
+ appConfiguration.getServerIp()));
log.info("RealmEntry___" + hostRealm + ":"
+ AvpContants.ORIGIN_HOST + ","
+ appConfiguration.getServerIp());
org.jdiameter.client.impl.helpers.AppConfiguration extensionPoints = (org.jdiameter.client.impl.helpers.AppConfiguration) getChildren(Extensions.ordinal())[0];
extensionPoints.add(InternalPeerController, "com.sntele.surfing.ability.ocs.test.MyPeerTable");
}
}
2.构造命令ccr与发送命令到ocs
Session session = factory.getNewSession();
// createRequest(int commandCode, ApplicationId appId, java.lang.String
// destRealm, java.lang.String destHost)
Request request = session.createRequest(command,
org.jdiameter.api.ApplicationId.createByAccAppId(vendorId,
acctApplId), hostRealm);
AvpSet avpSet = request.getAvps();
// {Auth-Application-Id} DCCA 4
avpSet.addAvp(AvpCode.AUTH_APPLICATION_ID,4,true,false);
// {Service-Context-Id}
avpSet.addAvp(AvpCode.SERVICE_CONTEXR_ID,AvpContants.SERVICE_CONTEXT_ID_ISMP,true,false,false);
// {CC-Request-Type} 4 - EVENT_REQUEST
avpSet.addAvp(AvpCode.CC_REQUEST_TYPE,4,true,false);
// {CC-Request-Number} 0
avpSet.addAvp(AvpCode.CC_REQUEST_NUMBER,0,true,false);
...........................................
Future<Message> future = session.send(request, timeOut,
TimeUnit.SECONDS);
(Answer) future.get();
3.解析ocs返回的cca信息
log.info("验证OCS请求返回信息 start");
int commandCode = answer.getCommandCode();//命令码
log.info("返回的命令编码:" + commandCode);
int resultCode = answer.getResultCode().getInteger32();//结果码
AvpSet avpSet = answer.getAvps();//返回数据集合
三.如果在dwr命令中断时,由于心跳连接(dwr)被封装在jdiameter内,可通过以下方法得知连接什么时候断开
在ClientConfiguration类加入:
org.jdiameter.client.impl.helpers.AppConfiguration extensionPoints = (org.jdiameter.client.impl.helpers.AppConfiguration) getChildren(Extensions.ordinal())[0];
extensionPoints.add(InternalPeerController, "test.MyPeerTable");
创建MyPeerTable类(继承与PeerTableImpl),并重写ActionContext的sendDwrMessage()方法即可
分享到:
相关推荐
微软Office OCS 配置、使用说明书
OCS培训课件
OCS&CBS系列培训教材之OCS系统流程及外部接口.
如何在子域安装OCS Server,图示
ocsocsocsocsocscosocsocsocsocs
详细讲述了exchange2007 UM与 OCS 2007 的整合
ocs详细部署文档,一步步指南,IT人士专用
从公司的HRDB中读取数据同步到AD中,并同时开始人员的Exchange与OCS帐号,已经组织的Exchange帐号
OCS一卡通消费系统操作手册(A4)V228.doc,OCS一卡通消费机概述安装与配置说明POS01消费终端操作说明
在安装Oracle9i,遇到“File not found D: \oracle\ora92\ocs4j\admin\OCS4J.properties”,点击忽略也能完成安装,但是又担心有不妥,于是四处查找答 案,不过也没有看到对这个东东的解释。 经过反复尝试,终于找到...
简介 1 Office Communications Server 2007 Enterprise Edition 概述 1 基础结构要求和先决条件 2 Enterprise Edition 部署概述 4 步骤 1:准备 Active Directory 架构、林和域 5 步骤 2:安装 SQL Server 6 ...
OCS Inventory NG安装后 提示三个错误解决方法
OCS 2007 R2 Client. Office communicator.
告诉你如何配置ocs R2和Asterisk进行互联。
阿里ocs的java客户端demo,我测试了xmemcached和spymemcached。两个都可用,但xmc可以交由spring管理client对象的生命周期,而spymc却是spring能创建但无法关闭,研究结果为:用xmc来做客户端,需注意的地方就是...
华为的OCS内部培训资料,绝密啦。。要下的朋友速度了!
OCS-3F2.1超声波氧气传感器数据手册
轉載微軟OCS 2007R2 CWA 安裝說明.
中文的OCS2007部署手册,在国内很少,有利于学习,请多多下载。
OCS Inventory 也可以用来发现在您网络中所有的活动设备,例如,交换机、路由器、网络打印机,这其中的每一个,您都可以通过 MAC 或者 IP地址来对它们进行分类。当OCS Inventory 管理控制台是运行在LINUX 上时,如果...