Avaya Java TSAPI SDK

  最近阶段性工作完成了,正好有点时间,就开始了之前比较好奇也比较感兴趣的一个工作,Avaya TSAPI JAVA SDK, 做这个事情的初衷是因为看熟悉的人做Avaya CTI其中TSAPI协议的集成基本上都是用C语言的dll或者so文件,然后通过java jni做封装,avaya没有提供java版本的TSAPI SDK;有了JAVA TSAPI SDK 就可以很方便的去开发出基于Avaya的相关应用;


    SDK 主要包含做了一下几个工作:

  1.   对所有请求响应做了同步处理,调用起来更方便,不需要通过invokeId来匹配;
  2.   在支持通话事件的同时,同时也接受AES发送的心跳,服务异常等事件,更方便的实现服务重连以及高可用;
  3.   简化了代码调用复杂性,提供简单的数据类型数据调用;
  4.   纯java代码,结构清晰,简单,跨平台 不依赖任何其他插件
  5.   支持所有avaya aes 提供的接口和事件(只要服务端支持的请求和事件都实现了)
  6.   一个sdk可以支持500并发以上的坐席呼叫中心

    呼叫&设备&坐席状态相关请求列表(字母顺序):

  1. alternateCall
  2. answerCall
  3. clearCall
  4. clearConnection
  5. conferenceCall
  6. singleStepConferenceCall
  7. consultationCall
  8. deflectCall
  9. pickupCall
  10. holdCall
  11. makeCall
  12. makePredictiveCall
  13. queryMwi
  14. queryDnd
  15. queryFwd
  16. queryAgentState
  17. queryDeviceInfo
  18. reconnectCall
  19. retrieveCall
  20. setMwi
  21. setDnd
  22. setFwd
  23. setAgentState
  24. transferCall
  25. singleStepTransferCall

呼叫&设备&坐席状态&路由相关事件(字母顺序):

  1. callClearedEvent
  2. conferencedEvent
  3. connectionClearedEvent
  4. deliveredEvent
  5. divertedEvent
  6. establishedEvent
  7. failedEvent
  8. heldEvent
  9. networkReachedEvent
  10. originatedEvent
  11. queuedEvent
  12. retrievedEvent
  13. serviceInitiatedEvent
  14. transferredEvent
  15. doNotDisturbEvent
  16. forwardingEvent
  17. loggedOnEvent
  18. loggedOffEvent
  19. privateEvent
  20. routeSelect
  21. routeUsedEvent
  22. routeEndEvent

监控相关相关请求(字母顺序):

  1. monitorDevice
  2. monitorCall
  3. monitorCallsViaDevice
  4. changeMonitorFilter
  5. monitorStop  
  6. monitorEnded
  7. snapshotDeviceReq
  8. snapshotCallReq
  9. escapeService  

系统状态事件(字母顺序):

  1. escapeServiceConf  
  2. sysStatReq  
  3. sysStatStart  
  4. sysStatStop  
  5. changeSysStatFilter  
  6. sysStatEvent   

下面是一个简单调用例子

package tsapi.client;


import com.avaya.jtapi.tsapi.csta1.CSTAGetAPICapsConfEvent;
import com.avaya.jtapi.tsapi.csta1.CSTAMakeCallConfEvent;
import com.avaya.jtapi.tsapi.csta1.CSTAQueryAgentStateConfEvent;
import com.avaya.jtapi.tsapi.csta1.LucentMakeCallConfEvent;

import tsapi.test.TsapiTestUnsolicitedHandler;
import tsapi.util.AgentStateEnum;
import tsapi.util.CSTAResponse;

public class TsapiClientTest {

	public static TsapiClient tClient;
	
	public static void main(String[] args){
		
		TsapiCustomUnsolicitedHandler eventHandler = new TsapiCustomUnsolicitedHandler();
		tClient = new TsapiClient("AVAYA#CM#CSTA#AES", "username1", "pwd1", eventHandler);
		tClient.init();
		tClient.monitorDevice("6810");
		/*
		tClient.monitorDevice("32171");
		tClient.agentLogout("16122", "6810", null, null);
		tClient.agentLogin("16122", "6810", null, null);
		tClient.agentNotReady("16122", "6810", null, null, (short)2);
		tClient.agentWorkNotReady("16122", "6810", null, null);
		*/
		CSTAResponse _evt = tClient.queryAgentState("16122");
		CSTAQueryAgentStateConfEvent _queryConf = (CSTAQueryAgentStateConfEvent) _evt.getResponseInfo().getEvent(); 
		System.out.println(AgentStateEnum.getAgentStateFromCode(_queryConf.getAgentState()));
		
		/*
		CSTAResponse _evt2 = tClient.getApiCaps();
		CSTAGetAPICapsConfEvent e = (CSTAGetAPICapsConfEvent) _evt2.getResponseInfo().getEvent();
		System.out.println(e.print());
		*/
		
		CSTAResponse _evt2 = tClient.makeCall("7810", "901811111111", "_test");
		CSTAMakeCallConfEvent _mkcE = (CSTAMakeCallConfEvent) _evt2.getResponseInfo().getEvent();
		LucentMakeCallConfEvent _mkcE2 = (LucentMakeCallConfEvent) _evt2.getResponseInfo().getPrivData();
		System.out.println("newcall " + _mkcE.getNewCall().getCallID());
		System.out.println("ucid " + _mkcE2.getUcid());
		
	}
}

下面是事件的简单处理例子

package tsapi.client;


import com.avaya.jtapi.tsapi.csta1.CSTAConnectionID;
import com.avaya.jtapi.tsapi.csta1.CSTAEstablishedEvent;
import com.avaya.jtapi.tsapi.csta1.CSTAEvent;
import com.avaya.jtapi.tsapi.csta1.CSTAServiceInitiatedEvent;
import com.avaya.jtapi.tsapi.tsapiInterface.TsapiUnsolicitedHandler;

import java.net.SocketException;
import org.apache.log4j.Logger;

public class TsapiCustomUnsolicitedHandler implements TsapiUnsolicitedHandler {
	private static Logger log = Logger.getLogger(TsapiCustomUnsolicitedHandler.class);

	public TsapiCustomUnsolicitedHandler() {
	}

	public void acsUnsolicited(CSTAEvent event) {
		System.out.println("TsapiLightweightUnsolicitedHandler acsUnsolicited saw unexpected event " + event);
	}

	public void cstaEventReport(CSTAEvent event) {
		System.out.println("TsapiLightweightUnsolicitedHandler cstaEventReport saw unexpected event " + event);
	}

	public void cstaRequest(CSTAEvent event) {
		System.out.println("TsapiLightweightUnsolicitedHandler cstaRequest saw unexpected event " + event);
	}

	public void cstaUnsolicited(CSTAEvent event) {
		//System.out.println("TsapiLightweightUnsolicitedHandler cstaUnsolicited saw unexpected event " + event);
		if(event.getEvent() instanceof CSTAServiceInitiatedEvent){
			CSTAServiceInitiatedEvent _evt = (CSTAServiceInitiatedEvent) event.getEvent();
			System.out.println(_evt.getInitiatedConnection().getCallID()); 
		}else if(event.getEvent() instanceof CSTAEstablishedEvent){
			CSTAEstablishedEvent _evt = (CSTAEstablishedEvent) event.getEvent();
			CSTAConnectionID cstaId = _evt.getEstablishedConnection();
			//System.out.println(cstaId.get);
			TsapiClientTest.tClient.singleStepTranferCall("7810", cstaId.getCallID(), "7819");
			
		}
	}

	public void eventDistributorException(Exception e) {
		if ((e instanceof SocketException)) {

			System.out.println("TsapiLightweightUnsolicitedHandler eventDistributorException: normal 'Socket closed'.");
		} else {
			System.out.println("TsapiLightweightUnsolicitedHandler eventDistributorException: unexpected exception received: "
					+ e);
			log.error(e.getMessage(), e);
		}

	}
}

 

因为开发也花了一定时间精力,所以就不无偿提供了,有需要的可以回复或者添加微信 

Avaya Java TSAPI SDK_第1张图片

 

 

 

 

 

你可能感兴趣的:(Avaya)