AJAX polling method not working?

Want to show realnames of users instead of plain usernames?

Download the drupalchat.module file that i am attaching and have both.

To the module coders: Feel free to get the AJAX fix included on newer version by looking for the changed code where it produces the $messages variable. The problem was that it would only create messages if $message_count > 0, and thats only used in longpolling, so remove the while bruckets from the json object.

It would be wise to make a better implementation of the realname module inclusion by using the code of the file whilist writing a function to check if the realname module is present and users want to use that instead, the current is hardcoded and it will only work to those who already have realname module. Another good thing is that by looking the realname table we avoid getting slow queries on the much bigger user table.

Feel free to test and try it out, original file has been from the dev version of the 17th Sept 2011.

CommentFileSizeAuthor
drupalchat.module.txt13.09 KBnevron
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

darklrd’s picture

Hey nevron

Thanks for your contribution. I ll review and commit it.

Cheers

darklrd’s picture

Just a quick question. What will happen if someone hasn't installed realname module? I guess this code makes realname module a dependency. Anyway great contribution. Will modify and include it. Thanks.

nevron’s picture

Yes darklrd that is true. For those who have not installed the realname module then they should definately NOT use the code as is. It is for the maintainers of the project in order to speed up the develpment of some requests regarding the realname usage. I believe there should be a new option on the admin.inc file that would be shown for someone to choose if he would want to make use of it and if realname is installed. If someone have selected it then it would be easy to implement the same queries using a variable that either has the original values of the code or if realname option is selected it would change to those as in the attachment i have supplied. I could do it and send you a dev cut in diffs when i have the time but i think you would be faster at it :) If you need help let me know and i'll have a look at it. At the mean time i'll be testing the ajax method on a production server and see what comes up. I have already aranged to make more cron calls in order for the messages to get deleted cause something tells me if it is going to be used alot then the drupalchat_msg table will be increasing exponentialy and thus making some of the queries slower, we got to think about that too.

darklrd’s picture

Yes, I will do that :) Thanks for your contribution and suggestion.

Regarding cleaning up of drupalchat tables, it is already handled by hook_cron() if the cron has been setup properly.