Hi,

so I've been using nodejs integration alongside privatemsg and privatemsg_nodejs modules to create custom live messaging functionality and I have recently stumbled on a particular problem so I'm gonna try to explain it as much as possible.

Let's say we have a standard threads and inside every thread, there is 1-x messages. Every thread has it's own message channel so if you want to get the updates in a thread (new messages and stuff), you need to "sign" for a channel using a token. You can do that usually in hook_init?, hook_page_build, custom callback function etc. (dunno which aproach is the correct one, privatemsg_nodejs is calling token in page_build and custom hook_menu callback function). You do all that before the page is rendered, but there lies a problem.

I am currently loading the thread (all its messages) into one page using standard jQuery ajax $.ajax and then i replace the content with the data returned from ajax callback function. I usually send content channel token for that specific thread I am returning through ajax callback. The function returns success but when I send message to that channel, the user never recieves it. The specific Drupal.Nodejs.callback never gets called. As if the channel token would never be opened for that specific thread.

If I do open that specific channel during page_build and then load the data using ajax, it works properly. But that solution can't be used on production.

I also need to somehow close the previous channel when I load different thread.

Is there any way to do that? To open the channel for specific thread after ajax callback so it would work? And ofc to close the previous channel?

Thanks in advance for ANY kind of help.

Comments

rohlizde created an issue.

yuraosn’s picture

Hello, faced with the same problem, found a solution? How did this task come about?

yuraosn’s picture