DokuWiki Chat AJAX-driven plugin

Info

This chat plugin is AJAX driven so it means that you do not have to reload page to see new
incoming messages.

In the info-bar you can see the AJAX engine progress.

If you have Java enabled you can as well have nice sound notification of new messages, even with sound volume / muting.

There is already a bunch of AJAX chatting modules available out there. So why I made this one

It started as a improvement of Discussion plugin and ended in fully AJAX driven chat. I wanted
to test the technology and to learn something new.
How to use it
Just type your message into text field below and hit [Enter]. That's it...

Jump to demo page here.

Installation

If anybody wish to test this under own DokuWiki installation, feel free to download it here (version 1.1.2),
Mirror 1 here (version 1.1.2), or
Mirror 2 here (all versions).

As have been said, code is probably not ready yet so it may fail to work for you under some circumstances, especially if you have older DokuWiki version. Improvements shall follow…

Installation

Unzip chat/ directory into your DokuWiki plugins folder.
Use included local.php.dist and add its contents to your local.php settings file. Change the values accordingly at your will.

The DokuWiki uses the AJAX tookit library SACK for all AJAX operations.
For the chat plugin to work correctly, you need to update SACK with latest 1.6 version.
I provide in the installation zip updated version of SACK. It is only one file tw-sack.js. You will have to copy this file over the original file in /lib/scripts/ directory.
Original tw-sack.js 1.6 version comes from http://www.twilightuniverse.com/resources/code/sack/ where you can download complete package with documentation and demo.

Original file miss some “;” on the end of declarations and it did not work well with DokuWiki javascript compression. That is the only modification I made.

*SKULL* 2007 - 12 - 04 break link for " http://www.twilightuniverse.com/resources/code/sack/ " help please

User rights

Chat messages are stored into separate chat namespace under the page where it is included.
So this current page stores chat into :dokuwiki:plugin:chat:chat page. Reveal hidden content


You will have to setup user-rights (ACL) for chat namespace.

When only Read right is set, user can see the messages list but is not allowed to send
the messages.

Chat include

To include chat on your page, use:

~~CHAT~~

Chat can be included only once per page.

Older DokuWiki versions

Chat plugin has been developed under latest development DokuWiki version.

If you wish to run it on older versions, you will probably need to do some adjustments:

  • If your installation does not include events.js, download it and put it into lib/scripts directory
  • Edit ajax.php and change all occurrencies of
    $auth->getUserData(...)

    into

    auth_getUserData(...)

Server logs

In case you have access to your server configuration, consider excluding Chat plugin accesses from access.log.

This is how it can be done for Apache2 (example):

SetEnvIf Request_URI "^/wiki/lib/plugins/chat/ajax\.php$" dontlog
SetEnvIf Request_URI "^/wiki/lib/exe/indexer\.php$" dontlog
CustomLog /var/log/apache2/access.log combined env=!dontlog

Internal logic

There are rotating four AJAX checking states:

  1. First, new messages are polled each 5 seconds.
  2. After 30 seconds, checking interval is prolonged to 10 seconds.
  3. After another 30 seconds, checking interval is changed to 30 seconds.
  4. Now, mouse-movement over document window is monitored. If no mouse movement occures on document window in one minute, interval is again prolonged to 5 minutes which is longest checking interval.

Now as soon as any mouse movement occures, checking interval is changed back to
10 seconds and the cycle repeats again.

At any time if something is typed into message box, checking interval is changed back
to fastest 5 seconds immediately.

This logic ensures that if chatting heat goes high, messages are refreshed fast enough
and still if there are no people chatting for some time, the polling cools down so
the web-server is not overloaded with AJAX requests.

You can modify the timings of course, but use common sense here. Although AJAX polling
requests and responses are short chunks of data and usually complete very quickly,
if there is a lot of users that have the page with the chat plugin open in browser,
enough traffic can be generated to bring your server to its knees. So use it wisely…

It is also advised to use some sort of PHP accelerator on the server side to improve
performance1).

Development

History

  • 2006-11-22, Version 1.2
    • Removed notification Java applet and replaced with Flash version. This should be less invasive and more compatible solution. Used FlashMP3Player (under CreativeCommons license) and UFO tookit (under CC-GNU LGPL license) to embed it.
    • Fixed time handling regarding to time-zones. Chat modification times were not reported correctly to browser.
  • 2006-11-8, Version 1.1.2
    • Security: Limited length of Name field to 30 characters.
    • Security: Limited length of Message field. Can be specified in configuration
    • Security: Filtering of Name field. Now it can consist of alphanumeric characters, dashes, underscores, dots or spaces only.
    • Added audio-notify setting into configuration.
    • Fixed cookies handling to work with newest DokuWiki
    • Provided updated Ajax toolkit library tw-sack.js (SACK 1.6 modified), you have to copy this over file in /lib/scripts/ directory. Original comes from http://www.twilightuniverse.com/resources/code/sack/
  • 2006-2-21, Version 1.1.1
    • Fixed regular expression in line parsing.
  • 2006-2-21, Version 1.1
    • Optimized sent data, really only new messages are transferred
    • Limited sending rate so it is not possible to send more than 1 message per second
    • Added $conf[’chat‘][’show-progress‘] for enabling info bar
    • [Clear messages] button is now visible for logged-in user that has edit rights for current page
    • Improved user-rights handling, now user must have write-rights for chat page to be able to see [Send] button and chat prompt.
    • More small fixes
  • 2006-2-20, Version 1.0
    • Added user rights checking
    • Added “Loading messages…" text on initial page load
    • Added error messages when user has insufficient rights

Chat

Comments

Anniyka, 2007-09-20

I noticed servel bugs in your code:

  • in the local.php.dist file, all variables concerning boolan values are not boolan in your case but only strings. It should be TRUE odr FALSE instead of ‘true’ oder ‘false‘.
  • in chat.php concerning the html-tag “param” you did forgot the / at the end for xhtml-compatibility.
  • in chat.php you use the date()-function to allocate a unique username in a wrong way.

Jaminos, 2007-11-21

Thank you for this plugin. It work great when I call it but I have a weird error on others namespaces.

I have a namespace with subnamespace and when i try to go on the sub-namespace, it transform the id from “projects:first_project” to “projectsfirst_project&1#chat“.

It delete the : between namespace and sub-namespace and it dont found the sub-namepace.

What I can do for fix this

1) Latest eAccelerator is maybe the best bet if you do not have this already
 
dokuwiki/plugin/chat.txt · Last modified: 2007/12/06 16:21 UTC by 217.128.107.102
 
Recent changes RSS feed Creative Commons License Donate to DokuWiki author Valid XHTML 1.0 Valid CSS Driven by DokuWiki Debian served Run on Apache Powered by PHP eAccelerated