After looking around for a JAVA client to add your Asterisk client library to, I came across JBother, http://www.jbother.org/. This client works fine with Jive Messenger before any changes. Once the very simple addition of a ring event handler is added the client fails to connect. This is logged to the console:
Exception in thread “Thread-7” java.lang.ClassCastException: org.jivesoftware.smack.PacketReader$4
at org.jivesoftware.smackx.ServiceDiscoveryManager.discoverItems(ServiceDiscoveryM anager.java:409)
at org.jivesoftware.smackx.ServiceDiscoveryManager.discoverItems(ServiceDiscoveryM anager.java:373)
at org.jivesoftware.phone.client.PhoneClient.(PhoneClient.java:58)
at com.valhalla.jbother.ConnectorThread.run(ConnectorThread.java:372)
at java.lang.Thread.run(Unknown Source)
In fact, adding the asterisk client library to the JAR without adding any code causes the connection to the server to take much longer.
Jbother, has an XML console and the asterisk ring events are being received. Changes to JBother are in only two files… ConnectorThread and build.xml. I would be happy to post them if given access.
JBother is also written using smack. My first guess is you are having a problem with the smack providers.
The smack providers from asterisk-im contains the following:
If these providers are not loaded correctly you will get a cast class exception when you try to case a Packet to one of the client api packet subclasses.
Looks like I have some reading to do on SMACK. I am not certain what you mean by “loaded correctly”. I confirmed that after the build the build/meta-inf/snack.providers file has the xml you posted. I’'ll see what I can learn from the SMACK documentation next.
If you want to post your source I can attempt to run my debugger against it. I should be able to find out pretty quick if something isn’'t getting loaded correctly.
I added asterisk-im-client.jar to the .\lib directory
I modified the build.xml adding asterisk-im-client.jar, my changes are attached
I modified .\src\com\valhalla\jbother\ConnectorThread.java, my changes are attached - search for my initials ‘‘WRC’’ to find the changes.
I used another class, MessageBox, to display a dialog box. I am certain that there are other ways to do this too. But if you need the code for that class too i can post it.
I do not see a way to attach the code to this so I may need my permissions changed unless you would like me to make it available some other way.
Instead of the release versions of all source code - I rebuilt with the last nightly build from JiveSoftware for the Asterisk-IM client (beta2) and SMACK/SMACKX. I also used the last nightly build from JBother.
It builds fine, and there are no runtime errors but no dialog is displayed when the extension i have programmed rings. In the XML console on JBother I do find the messages for RING and HANGUP events are received.
Looking at the source I sent, are any calls missing? Since JBother also uses SMACK and registers packet a packet listener do i need to somehow register the listeners together or serialize them?
Okay, finally success. I am able to capture a ring event although I was not able to do it by overriding the RingEvent… this approach never fired. However, adding a listener and overriding handle() to fire on allevents then checking the event status worked. I plan to play with it a bit more and will post the changes if anyone wants them.
It is probably more appropriate to move the discussions of what features should be implemented to the JBother forum… although UI am happy to do so here as this forum seems to be more active.
I also should restate the fact that this is the my first effort at writing any JAVA code so although I am pleased with the results, I recognize that I will probably need some assistance - any volunteers?
To summarize the problems… it had to do with bugs, I do not fully understand, that have been fixed in the most recent releases of JBother and SMACK. It would seem that there may still be a problem with the Asterisk-IM client library since the RingEvent override did not work. It was registered as follows:
Get the most recent nightly build of JBuilder using a subversion client, I downloaded TortoiseSVN from www.collab.net. It is very easy to use and integrates with the windows explorer. I retreived the latest src from:
In JBother this occurs in \src\com\valhalla\jbother\ConnectorThread.java. You can find the changes I made to this file in an earlier post… although I have since moved the call to instantiate the ‘‘PhoneClient’’ further down after the attempt to connect.
I also added another static declaration I found in the test class for the Asterisk-IM client library. There was very little code there but there were two calls to Provider.addExtensionProvider (“phone-event” … and ProviderManager.addIQPRovider (“phone-action” …
I do not know if that code is necessary but will remove it and see if everything still works. I will post my code after I play with it a bit more. I also am trying to determine if the best approach is to modify JBother directly or create a plugin. I have a question posted on the JBother forum to see if a plugin has access to the XMPPConnection instance.