I’‘m trying to port smack to J2ME and succeeded EXCEPT for one issue: getting rid of Smack’'s blocking API. The problem is that Smack depends on sockets that support simultaneously reading and writing from/to a socket (also called full-duplex sockets). I have an IM client that runs on every J2ME emulator you can think of, but on not one REAL phone. The problem is that there are not many phones available that support full-duplex sockets.
I had a long discussion with Mariano a while ago how I could solve the problem, but our conclusion was that it might very well be impossible. Read the conversation here:
Now some time has passed and I went back to the project. There’'s a lot of interest in it, certainly with the increasing popularity of XMPP. I still think it would be great if Smack was available for J2ME phones (the majority within a short time). BUT BUt But but…that still requires me to solve that last killing problem of full-duplex sockets.
I guess my question is whether someone else here has any idea how we could avoid this blocking behaviour and finally get Smack working on a real Java phone.
I ran an exercise yesterday to port the latest 1.4 smack library to J2ME. All was fine except for:
StringTokenizer (used Sun’'s class for now)
SimpleDateFormat (commented out the code for now)
Reflection (read below)
The reflection code for the event notification was easily ported to call the methods explicitly. The 2 parts that I couldn’'t do was parsing the XML via introspection, and streaming the property.
I will be doing some testing on this library. If anyone is interested in it, let me know.
Interesting! I would certainly be interested in the testing. Did you actually get it to work? Did you see the list of issues when porting I posted to this list earlier? There are definitely more than just the three you mention.
I guess Smack 1.4 still is a blocking API (still relies on full-duplex sockets), so you will run into the same problem I ran into; that such sockets are close to none-existent on real phones.
Currently I’‘m experimenting with a serverside J2SE proxy that takes 2 sockets (read and write) from a J2ME Smack client and ties them to one full-duplex socket to a jabber server. I’'ll post the results here.