Demo: Java2Script Google Talk in SWT
Pre-words
In March, I wrote “Java2Script version of Google Talk”. It was a very simple SWT application that talks to talk.google.com using Jabber XMPP protocol by Smack library.
About 3 months later, I rewrote the whole Java2Script version of Google Talk. In this time, I still used Smack library. But I used Instantiations’ Windows Builder Pro to help me to design the whole interface. And this time, it copied all existed UI from the desktop version of Google Talk, including every dialogs, menus or layouts. It looks almost exactly the same of Google Talk.
Here is the demo addres: http://demo.java2script.org/gtalk/
P.S. Other available web IM services provided by this Java2Script technologies:
Here are some screenshots:
Requirements
It is just trying to re-implement all the features of Google Talk except the voice talk. And all dialogs or layouts are copied from Google Talk, as I thought that Google Talk is excellent.
Architecture
Jabber Server (talk.google.com) –> XMPP –> Tomcat Server (Smack) –> mod_jk Connector –> Apache HTTP Server –> Browser Client
Implementation
Java2Script’ Simple RPC and Simple Pipe were used in the Java2Script Google Talk. Simple RPC serializes requests from browser to server, and server will parse them and send out related XMPP requests. All packets received from Jabber server are piped through Simple Pipe to the browser. The Simple Pipe just serializes XMPP packets into SimpleSerializable instances, and sends out through the comet HTTP connection.
That is to say, Simple RPC is OutputStream and Simple Pipe is InputStream in Java’s terms. And all data are serialized or deserialized by SimpleSerializable.
Optimization
JavaScript and DOM manipulation is very slow actually. And loading bundles of *.js from server to browser also requires a very long waiting. In order to improve the performances, lazy loading technologies are applied.
First, lazy loading those *.js related to the UI until the UI is required. For example, chatting dialog related classes’ *.js only be loaded when user open a chatting dialog or a message is received. This principles are also applied to settings dialogs, inviting friends dialogs and others. To lazy loading *.js, AClass or ASWTClass is introduced in Java2Script. It will load classes only when needed. The usage of A/SWT/Class is as following:
ASWTClass.shellLoad ("org.java2script…..", new ARunnable () {
public void run() {
// begin to later action.
});
Second, some part of codes are executed lazily. For example, create menus may require a lot of CPU times for browser. So only before the menus are to be shown do the menus are being created. In such a way, only what you see on the UI is created. Or they won’t be created by default.
Third, virtual list is used to avoid large friends list updating. For example, if there are more than 200 friends on one’s Google Talk friends list and concrete SWT widgets are created according to each friends, there will be 200 widgets being created. And it will freeze the whole browser UI. And when the dialogs are resized, re-layout these hundreds of widgets may also freeze browser. To avoid such freezing, virtual list is introduced. The virtual list is that only visible list item are created. Those invisible items are never created. In such a way, 500+ friends are supported.

August 7th, 2007 at 2:01 pm
I liked that web based google talk..
really good interface.. 4 chat..
need to improve little..
August 9th, 2007 at 8:18 am
Yes, a lot of works need to be done before it becomes an application or a service.
August 9th, 2007 at 11:15 pm
用Javascript寫成的GTalk…
今天在非Google官方Blog看到的一篇文章,Java2Script(以下簡稱J2S)的作者Zhou Renjian成功的把GTalk寫成Javascript的版本了。\r\n\r\n我看了一下這些資料才知道,J2S是把eclipse(一種原本用來開發Java的IDE…
August 15th, 2007 at 11:31 am
The programme is so good. but UI is simple. Reorganizing the interface is better.
August 16th, 2007 at 9:31 am
O, the UI is Google Talk’s things. Just a complete copy.
September 30th, 2007 at 8:28 pm
[…] 其次,我还是直接地完整抄Google Talk的界面,包括图片、皮肤、风格等。 […]
April 16th, 2008 at 11:46 am
Oops, great work…., really great… keep rocking….
August 18th, 2008 at 7:36 pm
I was trying to use the application but I don’t know what is wrong, either the application is too slow or is not working, i tried with Firefox 3.0.1, IE7 and Safari but none seem to be working
September 23rd, 2008 at 7:18 am
@Sharad and others
Now the Java2Script Gtalk demo should be working. Try it out.
October 19th, 2008 at 7:24 pm
that shit , it takes many cpu ressources, i just tried it and my cpu went all freaky, review your program completely dude
October 23rd, 2008 at 12:41 am
@cris
Thanks for pointing out CPU problem.
From our tests, CPU is not a big problem. Would you like to provide more information about your environment, including CPU, memory and browser.
We frequently review and modify our program for a better web instant messenging user experience.