Adding support to JBother Client

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.

synic (http://www.jivesoftware.org/forums/profile.jspa?userID=5427) is a developer of JBother. PM or email him. Maybe he can advice you better.

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.

First download the source to JBother from: http://www.jbother.org/index.rb?command=download

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.

Thanks.

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.

You now have permission to post attachments.

Regards,

Matt

we are wating for yours attachments

Regards,

Saleh

Thanks, - I waited up for a while for the permissions to change but at 1:30am my time (EST) I turned in for the night.

Here are the files. Search for ‘‘WRC’’ to find my changes - which are currently commented out in the .java file.

In the root of the JBother project, there is a file that implies the authors made some changes to smack. I attached it too: smackchanges.patch

Message was edited by:

wrcgator

Message was edited by:

wrcgator
smackchanges.patch (83276 Bytes)
ConnectorThread.java (19749 Bytes)
build.xml (2752 Bytes)

Looks like others are as anxious as I am to have a client that supports Asterisk-IM…

Buildfile: build.xml

debug:

init:

compile:

Compiling 174 source files to /tmp/JBother/JBother/build

/tmp/JBother/JBother/src/com/valhalla/jbother/ConnectorThread.java:43: cannot access org.jivesoftware.phone.client.event.PhoneEventPacketExtension

bad class file: /tmp/JBother/JBother/lib/asterisk-im-client.jar(org/jivesoftware/phone/client/e vent/PhoneEventPacketExtension.class)

class file has wrong version 49.0, should be 48.0

Please remove or make sure it appears in the correct subdirectory of the classpath.

import org.jivesoftware.phone.client.event.PhoneEventPacketExtension;

^

1 error

BUILD FAILED

/tmp/JBother/JBother/build.xml:89: The following error occurred while executing this line:

/tmp/JBother/JBother/build.xml:17: Compile failed; see the compiler error output for details.

Total time: 4 seconds

Thanks for any help

You need to copy asterisk-im-client.jar into your ./lib directory. You can download it from: http://www.jivesoftware.org/asterisk-im/clients.jsp

Also, I used another class for the DialogBox… there is probably another way to simply pop up a dialog without this class so I did not include it.

Progres but no cigar.

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?

Message was edited by:

wrcgator

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:

client.addEventListener(new BasePhoneEventListener() {

// Override the onRing event to see when we are receiving a call

public void onRing(RingEvent event) {

log.info("receiving a call from " + event.getCallerID());

}

});

how can I rebuilt it with the last nightly build

can you PLZ give the steps

Thanks

Regarads,

Saleh

I rebuilt it with the last nightly build successful ))))))))))

Extracting the Contents of a JAR File

jar xf JBother.jar

Thanks all

Regrads,

Saleh

Problems:

Aug 16, 2005 1:19:32 PM org.jivesoftware.phone.client.event.PhoneEventPacketExtensionProvider parseExtension

SEVERE: Could not find type attribute

wheen incoming call came

  1. come DialogBox

titele

Connection Errors

Could not find type attribute

  1. XML Console:
  1. JBother go offline

Regarads,

Saleh

Here are the steps I went through

  1. Install JDK 5.0

  2. 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:

svn://jbother.org/usr/local/svn/JBother

  1. Get the latest nightly build of the SMACK libraries from: http://www.jivesoftware.org/nightly.jsp

Copy the smack.jar and smackx.jar to \lib directry - where is the directory where you saved the JBother source

  1. Get the Asterisk-IM client library, asterisk-im-client.jar, and copy to the JBuilder source tree in the \lib directory

  2. Edit the build.xml file and update for asterisk-im-client.jar - I posted the changes I made earlier in this thread.

  3. The asterisk-im-client documentation (http://www.jivesoftware.org/messenger/plugins.jsp?plugin=asterisk-im.jar&showRea dme=true) suggest making the call to instantiate a ‘‘Phone Client’’ after the call that creates an XMPP Connection:

XMPPConnection conn = new XMPPConnection(“myserver.foo.com”);

PhoneClient client = new PhoneClient(conn);

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.

Message was edited by:

wrcgator

Message was edited by:

wrcgator

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.

The event classes themselves should not be overriden. Doing this would require you to write a new PacketExtensionProvider to parse the events.

Everything in the asterisk-im client library is intended to be used by adding listeners.

I may not have described what I was doing properly. I used the example in the asterisk-im-client documentation:

http://www.jivesoftware.org/messenger/plugins.jsp?plugin=asterisk-im.jar&showRea dme=true

Here is the code:

PhoneClient client = new PhoneClient(conn);

client.addEventListener(new BasePhoneEventListener() {

// Override the onRing event to see when we are receiving a call

public void onRing(RingEvent event) {

log.info("receiving a call from " + event.getCallerID());

}

});

This is what I did but I never received the ring event eventhough i could see the xml packet come in.