Forum OpenACS Development: ajax based chat as xowiki page

Collapse
Posted by Gustaf Neumann on
Hi folks, i have checked into cvs HEAD a small extention to xowiki, that implements the client and server side of a ajax based chat system. This is implemented via the programmable xowiki::Object class. i have implemented the system from scratch, since, i was just interested in getting some experience with ajax, but - aside from javascript quirks - this worked quite nicely. Here you can see an xowiki page with categories and the xowiki chat embedded.
http://media.wu-wien.ac.at/download/xowiki-doc/ajax-chat.png
Login into the chat happens simply by loading the xowiki page. I have tested with safari and firefox.

in order to try the xowiki ajax chat, load the following file from the browser and you will create in that xowiki package instance a page named en:ajax-chat.

http://.../xowiki/admin/samples/ajax-chat

I have tried to make the display as flicker-free as possible, this works quite well. every chat is identified by a chat-id, which could be in general a package_id, community-id, or whatever. the chat-id is configured in the wiki-page and is set currently to 22. There are some more limitations: Currently, only one chat is allowed per browser. if the login times out, the background process is not able to login automatically. so far, the chat is volatile, that is, the messages are not logged to the database or to some log file, but that's not complicated at all.

The length of the code in the content-part (you will see this by editing the page) can and will be reduced, such that only the configuration stays there. i am not sure yet, how much of this should go to the library...

Collapse
Posted by Hamilton Chua on
Coolness !!!!

I don't know if this will help reduce the code in the "content-part" but I put together a little Ajax Helper package that uses the prototype.js and scriptaculous javascript libraries.

It's currently in use in a custom Tag Cloud package in Solutiongrove's Aspen Private Label Communities product and an ongoing project that uses xowiki and portlets.

The package also allows you to use tcl to generate the javscript for cinematic effects like fades and transitions so you can actually put transition effects when the chat screen is updated via ajax.

I was hoping to commit it to OpenACS Head once I've completed the documentation and demos.

Collapse
Posted by Gustaf Neumann on
the "content-part" is currently 25 lines (including the form, url-definitions, etc.) and should be reduced to 10 or so. i am not sure, whether the .js libraries your are mentioning will help with that.

the bigger question is, how many XMLHttpRequests for one browser we want to have more or less in parallel, how to address the multiple instances of one app in browser windows/tabs (names of dom elements), how to bundle/multiplex multiple inquirers in a single HTTPrequests and answer sets. In other words, would not be optimal, if for every ajax application instance, separate XMLHttpRequests whould be created, all of these polling the server for updates. one poll should provide data for all inquirers. registering callbacks in js look like a good idea...

The situation might be different in your situation, i would assume, that once the "cinematic effects" are done (whatever these are) no more requests are needed.

Collapse
Posted by Hamilton Chua on
Hi Gustaf,

These are the same big questions that I dealt with when I was looking into xmlhttpd about 1 year ago when it started gaining momentum. But then things got busy and I was unable to pursue it.

It's a good thing too because between then and now a plethora of javascript libraries and ajax toolkits have been released that address those same questions.

I've just committed to OpenACS CVS Head the Ajax Helper package. Instead of re-inventing the wheel I decided to re-use what is available by utilizing Scriptaculous and the prototype javascript library.

http://cvs.openacs.org/cvs/openacs-4/packages/ajaxhelper/

A demo site will follow very soon.

Cheers,

Hamilton

Collapse
Posted by Rainer Hahnekamp on
Hello Hamilton,

I've tried out your AjaxHelper package and find it is a very useful addition for OpenACS. But I am afraid it produces too much overhead.
If I have for example a page where I only want to use that bubblecallout feature - which should be a very trivial one - the loading time of the page increases from approximately 1 second to over 6 seconds!
Perhaps one can reduce the amount of javascript files that are loaded by default to an absolute minimum.

Greetings,
-Rainer

Collapse
Posted by Hamilton Chua on
Hi Rainer,

Thanks for the feedback.

Hamilton

Collapse
19: ajax helper demo (response to 16)
Posted by Hamilton Chua on
Oh and have you seen the demo ?
It's on a temporary server

http://sgsandbox.com:8002/xowiki/demo

username : mailto:demo@solutiongrove.com
password : demo

Collapse
20: Re: ajax helper demo (response to 19)
Posted by Gustaf Neumann on
wow; this is looks indeed very nice! maybe this is developing to an alternative to the portlets + portal pages...
Collapse
21: Re: ajax helper demo (response to 19)
Posted by Malte Sussdorff on
I seriously hope this develops into an alternative to the way we handle portlets and portals at the moment. I'm missing though a "save" function :).

Furthermore it does not work on Safari.

Collapse
Posted by Gustaf Neumann on
another thing to mention: in the current version, a user cannot chat to himself: in order to minimize the traffic, the chat remembers for every user_id the timestamp he has already seen, and sends only newer messages (happens via nsv_*). so one needs 2 users to try this out.
Collapse
Posted by Gustaf Neumann on
there is a new version of my ajax based chat package checked in cvs HEAD, most of the mentioned shortcomings are removed. Every chat client has a session-id now, a single user logging in from two browsers or two browser frames gets now a different id, so the user can to himself - not, that this is important, but should work anyhow. the chat works now with IE as well.

if you edit the page en:ajax-chat, you see that its contents are reduced now to

	proc content {} {
	  ::xowiki::Chat login -chat_id 22
	}
By removing the chat_id, per default the package_id is used as chat_id (this means one chatroom per package instance). If it is left as it is, no matter from which instance of xowiki this is coming, the chat connects to a chatroom with chat_id 22.