Using context.module or panels.module I would like to have multiple chat windows on a single page.


Title:Allow multiple chat windowsAllow multiple chat fields
new1.91 KB

Patch attached. I wouldn't be surprised if there is a more efficient way of doing this.

Status:Active» Needs review

thanks, will review tonight/tomorrow.

Status:Needs review» Needs work

the intention of this line in chatroom.module is to key each chat by it's cid, so we can have multiple on the page by allowing multiple to be sent down in Drupal.settings.chatroom.chats:

(array('chatroom' => array('chats' => array($chatroom->get('cid') => $chatroom_settings))), 'setting');

and this snippet in chatroom.js is meant to process them:

* We depend on the Nodejs module successfully create a socket for us.
Drupal.Nodejs.connectionSetupHandlers.chatroom = {
connect: function () {
    for (var
cid in Drupal.settings.chatroom.chats) {
Drupal.chatroom.initialised = true;

so, the current code at least intends to handle the multi-chat window case.

what errors where you seeing that led to this patch?

When there is a single chat window on the page Drupal.settings.chatroom.chats is an object. When there are more than one it is an array of objects. The patch checks if it is an object or an array, and if it is an array it finds the proper object to work with.

The patch doesn't change anything in Drupal.Nodejs.connectionSetupHandlers.chatroom. The only problems I ran into was in Drupal.chatroom.initialiseChat(Drupal.settings.chatroom.chats[^edit-chatroom-message-entry-box-/, '')]; is undefined)

ok, cool.

so the bug seems to me that it should always be an object, keyed by the cid of the chat. does that make sense? i'd rather make php send down js that can always be addressed the same way rather than adding a special case check to the js.

It makes some sense but I'm not sure how to make it work as desired. I've played around with the drupal_add_js() code from #4 but no luck.

So I'm starting to understand this better.

Right now:

drupal_add_js(array('chatroom' => array('chats' => array($chatroom->get('cid') => $chatroom_settings))), 'setting');

Results in Drupal.settings.chatroom.chats being:

[Object, Object]

When there are two chat windows on the page.

We want it to be:


And each chat object will be a property of this Object keyed by cid (as described in #7).

There seems to be something getting messed up in the PHP->JS as:

drupal_add_js(array('chatroom' => array('chats' => array('x' . $chatroom->get('cid') => $chatroom_settings))), 'setting');

Will end up with the correct format, only it has 'x' appended to each key.


drupal_add_js(array('chatroom' => array('chats' => array((String) $chatroom->get('cid') => $chatroom_settings))), 'setting');

Doesn't work.

Status:Needs work» Needs review
new975 bytes

I think we need to fix this once on the JS side.

i think i agree with this. we can even ditch the attempt to index by cid in php, and just add chats to the array.

i'm holding off committing this, however, because now that i'm really playing with multiple chats on the same page, i'm uncovering lower lever bugs in contentTokenChannel handling which i want to fix first.