Download CSTA Simple Example of Monitoring Extensions SNAPSHOT Jar
From February 1, 2010 here is a snapshot for talking to the CSTA Server which is talking to a Siemens Hipath 3000 PBX with a network connection (TCP).
Read the README.txt file for a little bit of info on how to run it.
The configuration file is:
CSTA_APPNAME=SIMPLECSTA #THE APP NAME, USED FOR OTHER CONFIGS
APP_CONFIG_FILE=simpleexample.conf #THE NAME OF THIS FILE
SIMPLECSTA_SERVER_PORT=6924 #THE PORT THE OPENCSTA SERVER IS LISTENING FOR CLIENTS
SIMPLECSTA_SERVER_ADDRESS=127.0.0.1 #WHERE THE OPENCSTA SERVER IS RUNNING
IMPLEMENTATION=SIEMENS_HIPATH3000_CSTA #WHICH PBX TO TALK TO
SIMPLECSTA_REPLACEDLEWITHDLEDLE=true #WHETHER 0x10 0x10 SHOULD CONVERT TO 0x10
SIMPLECSTA_REPLACEDLEDLEWITHDLE=true #WHETHER 0x10 SHOULD CONVERT TO 0x10 0x10
SIMPLECSTA_OPENCSTACLIENTSERVER=true #IS IT OPENCSTA CLIENT/SERVER COMMUNICATIONS
MONITORSTARTS=4011,4040 #EXTENSIONS TO START MONITORING ON YOUR SYSTEM
The source code is as follows:
package org.opencsta.simpleexample;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
import java.util.StringTokenizer;
import org.apache.log4j.Logger;
import org.opencsta.apps.objects.CSTAApplication;
import org.opencsta.client.CSTAMulti;
import org.opencsta.servicedescription.common.AgentEvent;
import org.opencsta.servicedescription.common.CallEvent;
/**
*
* @author cm
*/
public class SimpleExample implements Runnable,CSTAApplication{
Logger alog = Logger.getLogger(SimpleExample.class) ;
private boolean runFlag ;
private Thread cstaThread ;
private CSTAMulti csta ;
private Properties theProps ;
private String[] monitorThese ;
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
System.out.println(System.getProperty("file.encoding")) ;
System.setProperty("file.encoding", "ISO-8859-1") ;
System.out.println(System.getProperty("file.encoding")) ;
Properties someProps = loadPropertiesFromFile() ;
SimpleExample app = new SimpleExample(someProps) ;
app.run() ;
}
public SimpleExample(Properties _theProps){
this.theProps = _theProps ;
csta = new CSTAMulti(this,theProps) ;
cstaThread = new Thread(csta,"CSTA Thread") ;
cstaThread.start();
}
private static Properties loadPropertiesFromFile(){
return loadPropertiesFromFile("simpleexample.conf") ;
}
private static Properties loadPropertiesFromFile(String filename){
FileInputStream is ;
try {
System.out.println("Trying to load properties from: " + System.getProperty("user.dir") + "/" + filename) ;
is = new FileInputStream( (System.getProperty("user.dir") + "/"+filename) );
Properties props = new Properties() ;
props.load(is) ;
return props ;
}catch (FileNotFoundException ex) {
ex.printStackTrace() ;
} catch (IOException ex) {
ex.printStackTrace() ;
}
return null ;
}
public void run() {
getMonitoredExtensions() ;
setRunFlag(true) ;
for( int i = 0 ; i < monitorThese.length ; i++ ){
csta.MonitorStart(monitorThese[i]);
}
while( isRunFlag() ){
try{
synchronized(this){
wait(2000) ;
}
} catch (InterruptedException ex) {
}
}
try{
//shutdown or something like that.
}catch(Exception e){
e.printStackTrace() ;
}
}
public void CSTACallEventReceived(CallEvent event) {
alog.info(event.toString()) ;
}
public void CSTAAgentEventReceived(AgentEvent event) {
alog.info(event.toString()) ;
}
public void TDSDataReceived(String dev, String code, String data) {
throw new UnsupportedOperationException("Not supported yet.");
}
public void cstaFail() {
throw new UnsupportedOperationException("Not supported yet.");
}
/**
* @return the runFlag
*/
public boolean isRunFlag() {
return runFlag;
}
/**
* @param runFlag the runFlag to set
*/
public void setRunFlag(boolean runFlag) {
this.runFlag = runFlag;
}
/**
* @return the csta
*/
public CSTAMulti getCsta() {
return csta;
}
private void getMonitoredExtensions() {
String m = theProps.getProperty("MONITORSTARTS") ;
StringTokenizer st = new StringTokenizer(m,",") ;
String[] mons = new String[st.countTokens()] ;
int count = 0 ;
while(st.hasMoreTokens()){
String thisexten = st.nextToken() ;
System.out.println("Adding this exten to monitored extensions: " + thisexten ) ;
mons[count] = thisexten ;
count++ ;
}
monitorThese = mons ;
}
}
| Attachment | Size |
|---|---|
| openCSTA-simpleexample-SNAPSHOT-20100223.zip | 427.92 KB |
