基于windows服务实现电话呼叫
2009-09-29 16:31 $等待$ 阅读(420) 评论(0) 收藏 举报1 package com.lexing.sciomkits.webapp.webcall.service;
2
3 import java.util.Date;
4
5 import com.lexing.sciom.commons.event.SciomEvent;
6 import com.lexing.sciom.kernel.SciomObject;
7 import com.lexing.sciom.kernel.exception.SciomException;
8 import com.lexing.sciomkits.webcall.ScmUmsClientService;
9
10 public class ScmVoiceService extends SciomObject {
11 private static ScmVoiceService myInstance = null;
12
13 private final String myUmsTopic = "123jy.cti.req";
14 private final String myCeSenderModule = "sciomtorch";
15 private final String myCeSenderName = "218.108.102.51";
16 private final String myCeReceiverModule = "sciomvru";
17 private final String myCeReceiverName = "60.191.125.207";
18 public final String myCeEventType = "CallEvent";
19
20 public static synchronized ScmVoiceService getInstance(){
21 if( myInstance==null ){
22 myInstance = new ScmVoiceService();
23 }
24 return myInstance;
25 }
26
27 /***********************************************************
28 * 通过双通道外拨方式,建立语音通话
29 * @param authKey: 唯一会话ID;同时也是当前呼叫认证码
30 * @param callerId:主叫号码,通常指发起呼叫的一方
31 * @param calledId:被叫号码
32 * @param dialOrder:外拨顺序: 0-先拨被叫,非0-先拨主叫
33 * @throws SciomCoreException
34 **********************************************************/
35 public void outboundConf(String authKey,String callerId,String calledId,int dialOrder) throws SciomException{
36 if( authKey==null || authKey.length()==0 ) throw new SciomException("非法授权码");
37 if( callerId==null || callerId.length()==0 || calledId==null || calledId.length()==0) throw new SciomException("非法外拨号码");
38 if( !ScmUmsClientService.getInstance().isActive() ) throw new SciomException("内部错误,外拨请求转发失败");
39 try{
40 SciomEvent event = new SciomEvent();
41 event.getHead().setSenderModule(myCeSenderModule); 42 event.getHead().setSenderName(myCeSenderName);
43 event.getHead().setReceiverModule(myCeReceiverModule);
44 event.getHead().setReceiverName(myCeReceiverName);
45 event.getHead().setEventType(myCeEventType);
46 event.getHead().setEventId("20001");
47 event.getHead().setCreateTime(new Date());
48 event.getHead().setDescription("Two way outbound conference call");
49 if( dialOrder==0 ){
50 event.addBodyParam("callerId", callerId);
51 event.addBodyParam("calledId", calledId);
52 }else{
53 event.addBodyParam("callerId", calledId);
54 event.addBodyParam("calledId", callerId);
55 }
56 event.addBodyParam("sessionId", authKey);
57 event.addBodyParam("content", "none");
58
59 ScmUmsClientService.getInstance().publish(event,myUmsTopic);
60 }catch(SciomException ex){
61 throw new SciomException(ex.toString());
62 }
63 }
64
65 }
66

浙公网安备 33010602011771号