当前位置: 首页>>代码示例>>Java>>正文


Java ManagerConnectionFactory类代码示例

本文整理汇总了Java中org.asteriskjava.manager.ManagerConnectionFactory的典型用法代码示例。如果您正苦于以下问题:Java ManagerConnectionFactory类的具体用法?Java ManagerConnectionFactory怎么用?Java ManagerConnectionFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ManagerConnectionFactory类属于org.asteriskjava.manager包,在下文中一共展示了ManagerConnectionFactory类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: SipDao

import org.asteriskjava.manager.ManagerConnectionFactory; //导入依赖的package包/类
public SipDao(String sipHostname, int sipPort, String sipUsername, String sipPassword, long timeout) {
	this.sipHostname = sipHostname;
	this.sipPort = sipPort;
	this.sipUsername = sipUsername;
	this.sipPassword = sipPassword;
	this.timeout = timeout;
	factory = new ManagerConnectionFactory(this.sipHostname, this.sipPort, this.sipUsername, this.sipPassword);
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:9,代码来源:SipDao.java

示例2: sendNotification

import org.asteriskjava.manager.ManagerConnectionFactory; //导入依赖的package包/类
public Hashtable sendNotification(Notification notification, Device device)
		throws NotificationException {
	// Do the outbound
	Hashtable params = new Hashtable();
	String phoneNumber = "";
	if (!(device instanceof AsteriskDevice)) {
		throw new NotificationException(NotificationException.INTERNAL_ERROR, "Provided device is not a telephone device");
	}
	phoneNumber = ((AsteriskDevice)device).getPhoneNumber();
	try {
		BrokerFactory.getLoggingBroker().logDebug("Logging into asterisk server at "+asteriskHost+" with "+managerId+":"+managerPassword);
		ManagerConnection con = new ManagerConnectionFactory(asteriskHost, 
				managerId, managerPassword).createManagerConnection();
		con.login();
		OriginateAction origAction = new OriginateAction();
		origAction.setChannel("SIP/"+phoneNumber+"@"+id);
		origAction.setContext(context);
		BrokerFactory.getLoggingBroker().logDebug("Calling "+"SIP/"+phoneNumber+"@"+id);
		BrokerFactory.getLoggingBroker().logDebug("Extension "+extension+notification.getUuid()+device.getUuid());
		BrokerFactory.getLoggingBroker().logDebug("Context "+context);
		origAction.setExten(extension+notification.getUuid()+device.getUuid());
		origAction.setPriority(new Integer(1));
		ManagerResponse origResponse = con.sendAction(origAction);
		if (origResponse.getResponse().toLowerCase().indexOf("error") >= 0) {
			BrokerFactory.getLoggingBroker().logDebug("response="+origResponse);
			throw new NotificationException(NotificationException.TEMPORARILY_FAILED, "Error dialing (probably busy).  Will try again.");
		}
		con.logoff();
	} catch (Exception e) {
		BrokerFactory.getLoggingBroker().logError(e);
		throw new NotificationException(NotificationException.INTERNAL_ERROR, e.getMessage());
	}
	return params;
}
 
开发者ID:davidrudder23,项目名称:OpenNotification,代码行数:35,代码来源:AsteriskVoIPNotificationProvider.java

示例3: main

import org.asteriskjava.manager.ManagerConnectionFactory; //导入依赖的package包/类
public static void main (String[] args) throws Exception {
	DefaultAgiServer server = new DefaultAgiServer();
	//server.setPort(5060);
	ClassNameMappingStrategy strategy = new ClassNameMappingStrategy();
	server.setMappingStrategy(strategy);
	AgiServerThread thread = new AgiServerThread(server);
	thread.startup();
	System.out.println ("Server started");
	
	
	// Do the outbound
	ManagerConnection con = new ManagerConnectionFactory("10.10.10.1", "reliable", "reliable").createManagerConnection();
	con.login();
	OriginateAction origAction = new OriginateAction();
	origAction.setChannel("SIP/[email protected]");
	origAction.setContext("outgoing");
	origAction.setExten("999");
	origAction.setPriority(new Integer(1));
	ManagerResponse origResponse = con.sendAction(origAction);
	if (origResponse.getResponse().toLowerCase().indexOf("error") >= 0) {
		System.out.println ("Error: "+origResponse.getMessage());
	}
	System.out.println ("Originate Response = "+origResponse);
	con.logoff();
	
	while (true) {
		Thread.sleep(100000);
		System.out.println(".");
	}
}
 
开发者ID:davidrudder23,项目名称:OpenNotification,代码行数:31,代码来源:SimpleAsteriskTest.java

示例4: initialize

import org.asteriskjava.manager.ManagerConnectionFactory; //导入依赖的package包/类
public boolean initialize()
{
  VSensorConfig vsensor = getVirtualSensorConfiguration();
  TreeMap<String, String> params = vsensor.getMainClassInitialParams();
  
  ManagerConnectionFactory factory = new ManagerConnectionFactory(params.get("host"), params.get("username"), params.get("password"));
  
  managerConnection = factory.createManagerConnection();
  
  // get the name of the virtual sensor from the vsd
  vs_name = new String(vsensor.getName());
  
  // generate a random extension number between 9000-10000
  Random random = new Random();    
  Integer ext =  (int)((long)(1001 * random.nextDouble()) + 9000);
  vs_ext = ext.toString();
  
  try
  {
    // connect to Asterisk and log in
    managerConnection.login();
    
    connected = true;
    
    // delete previous configuration, e.g. dial plan and config files
    cleanConfig();
    
    // create the text-to-speech ulaw file
    text2speech_low(params.get("message"));
    
    // create the dial plan in the asterisk server
    createDialPlan(vs_name, vs_ext);
    
    // settings for making the actual phone call
    originateAction = new OriginateAction();
    
    phone_no = new String(params.get("number"));
    
    originateAction.setChannel("SIP/" + phone_no + "@" + SIP_TRUNK);
    originateAction.setContext(vs_name);
    originateAction.setExten(vs_ext);
    
    originateAction.setPriority(new Integer(1));
    originateAction.setCallerId("GSN Notification");
    
  } catch (Exception e)
  {
    connected = false;
    logger.error("connection state is " + managerConnection.getState() + "    "+ e);
  }
  
  vs_counter++;
  
  logger.info("Virtual Sensor [" + vs_name + "]" + " added to GSN with extension " + vs_ext +  " running instance @" + vs_counter);
  
  return connected;
}
 
开发者ID:LSIR,项目名称:gsn,代码行数:58,代码来源:VoipVirtualSensor.java


注:本文中的org.asteriskjava.manager.ManagerConnectionFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。