powered by Jive Software

The newest newbie has some questions

Hello,

I’‘ve been programming PHP for about 2 years. I just started with Java about 2 weeks ago. It’‘s my first standalone, GUI, and OOP language. It’‘s been fun, but at the same time “brain frying”. I decided that for my first project I would write an Instant Messaging client and possibly server. I started out believing that it wouldn’'t be a big deal to create my own protocol based on XML. I was wrong.

So now I have decided just to write a jabber client and run a jabber server. This IM client will eventually be used for inter-office communications.

I found out about smack from jabber.org. It looks to be a good library for my specific needs, however, the documentation is severely lacking for a person of my skillset.

So far I have been able to write a little program that creates two connections, and one connection sends a message to the other. This works fine.

I have been fiddling around with it to see what happens if the user is not online or does not exist when I try to send the message. An XMPPException is not generated like I think it’'s supposed to - and in fact, nothing actually happens in the program at all. The PacketListener of course never sees it. I do get this message in my server log:

20030716T02:17:41: (synic): bouncing a packet to synic from jabberuser@localhost/Smack: Server Connect Failed

How do I find out if the packet was actually sent?

Hi synic,

I’'m pretty new to Java myself and am using Smack to write a client as a learning tool.

First, I’‘d highly recommend Iain’‘s book. He works from ground zero developing a Jabber server and client not using the Smack library. While I would say the Java code is overall “intermediate” level, his code is very, very clean. If you’‘ve done previous development and get familiar with “listeners” and the various collection classes such as hashtables, you really won’'t have a problem following the book.

You’'ll find that in Java, the Javadocs are the main source for any API documentation…not just for “reference” as you may initially think. Most APIs (especially open source) give you Javadocs and, it your luck, a few examples of usage or a sample app.

Smack, in a way, contains 2 API’'s for Jabber depending on what your needs are which you can pretty much mix and match. Smack can handle the details for you or your can set up listeners to handle the various packets yourself.

As an added advantage, you get the source for Smack, which can be a great learning experience as well.

Anyway, I see your post has changed since I last saw it…so to answer a few of your questions:

Both of the scenarios you describe from your test would not generate an exception. In the case of the user being offline, the server will store the message for delivery until such time as the use comes back online. In the case of the user being non-existent, you should get a “404 not found” message back from the server.

To see what’'s going on as far as traffic between client and server, add the line: XMPPConnection.DEBUG_ENABLED = true; to your code. When you connect, Smack will pop up a GUI where you can see all the packets.

Talk to you later,

John

Welcome to the Java world! If you have specific suggestions for additional examples you’‘d like to see, please post them. Otherwise, we’'re happy to try to answer your specific Smack programming questions.

Regards,

Matt