05-19-2015 07:54 AM
I am trying to write a simple function to list device states but am getting an exception when I all getDeviceState.
The user that I use has the following only, in both Roles and Groups:
- Standard CTI Allow Control of All Devices
- Standard CTI Enabled
All devices from Available Devices list are moved into Controlled Devices. Available Profiles is empty.
Is there any configuration that needs to be done at the device level, or somewhere else for this to work?
Thanks in advance.
Here is the code:
JtapiPeer peer = JtapiPeerFactory.getJtapiPeer(null);
/* connect to the provider */
String providerString = hostname;
providerString += ";login=" + login;
providerString += ";passwd=" + passwd;
Provider provider = peer.getProvider(providerString);
CiscoProvider ciscoProvider = (CiscoProvider) provider;
final Condition inService = new Condition();
ciscoProvider.addObserver(new ProviderObserver() {
public void providerChangedEvent (ProvEv [] eventList) {
if (eventList == null) return;
for (int i = 0; i < eventList.length; ++i) {
if (eventList[i] instanceof ProvInServiceEv) {
inService.set();
}
}
}
});
inService.waitTrue();
Terminal[] terms = ciscoProvider.getTerminals();
System.out.println ("Found "+ terms.length +"terminals");
for(int i=0; i< terms.length; i++)
{
CiscoTerminal term = (CiscoTerminal)terms[i];
System.out.println(term);
try {
int x = term.getDeviceState();
System.out.println(x);
}
catch (Exception ex) {
}
finally {
}
Address[] addresses = term.getAddresses();
System.out.println ("Found "+ addresses.length +"addresses");
for(int j=0; j< addresses.length; j++)
{
CiscoAddress address = (CiscoAddress)addresses[j];
System.out.println(address);
}
}
provider.shutdown();
05-19-2015 07:58 AM
Forgot to mention the exception:
com.cisco.jtapi.InvalidStateExceptionImpl
05-19-2015 11:10 AM
You need to add observer on the terminal, wait till the state changes to in-service and then call this API.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide