Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm developping a livetracking module, I would like to be able to access publishMessageToContentChannel directly from my nodejs extension without having to go trought sendMessageToBackend.
My goal is just to speed up the publishing process of the tracker device to the users. Passing trought the backend is really bad for performance.
What I request is changing :
var extensionsConfig = {
'publishMessageToChannel': publishMessageToChannel,
'publishMessageToClient': publishMessageToClient,
'addClientToChannel': addClientToChannel,
'settings': settings,
'channels': channels,
'io': io,
'tokenChannels': tokenChannels,
'authenticatedClients': authenticatedClients,
'request': request,
'sendMessageToBackend': sendMessageToBackend
};
with
var extensionsConfig = {
'publishMessageToChannel': publishMessageToChannel,
'publishMessageToClient': publishMessageToClient,
'addClientToChannel': addClientToChannel,
'settings': settings,
'channels': channels,
'io': io,
'tokenChannels': tokenChannels,
'authenticatedClients': authenticatedClients,
'request': request,
'sendMessageToBackend': sendMessageToBackend
'publishMessageToContentChannel': publishMessageToContentChannel
};
I guess there might be some safety reasons why this function is not included by default into the extensionsConfig object but I can't see any at the moment.
Can I have some explanations on this topic please ?
++
Comments
Comment #1
Anonymous (not verified) CreditAttribution: Anonymous commentedthere's no good reason. initially, it was this way because when i wrote server.js i had NFI what i was doing with node.js code, and the extension stuff was added later, and is pretty clunky.
so, here ya go:
http://drupalcode.org/project/nodejs.git/commit/c45e63939bca75335ad335d4...
Comment #2
julien66 CreditAttribution: julien66 commentedThat's perfect.
=> Thank again Beejeebus !
Comment #3
julien66 CreditAttribution: julien66 commentedAnd now I feel stupid... !
Cleaning the livetracking module after having a working version I was trying to use this publishMessageToContentChannel function directly from node... And it eventually result in an error since it's built to handle a request from the backend ! (And not directly from Nodejs) :
I can't see any simple way of using this function directly.
I guess it involves a new way of writting the active nodejs functions for both 'direct' and 'from-backend' use. I'm not clever enough to find a clean way of doing it.
Beejeebus, any hint on this ?
I believe this is the last request to provide a clean livetracking module.
Thanks a thrillion !
++
Comment #4
rho_ CreditAttribution: rho_ commentedI've worked around this by modifying and including the function in my server extenstion. You'll need to pass the config variable along with your message, but seems to work alright.
I imagine something like this could be implemented in server.js and passed to the extensionsConfig object.
Comment #5
julien66 CreditAttribution: julien66 commentedYou rock rho_ !
I didn't realised the config object actually contained everything I needed to rebuild the function in my own extension. I commited the change to my project (marked commit as authored by you !) :
=> https://drupal.org/node/2035675/commits
@Beejeebus, please forgot about the previous patch.
I close the issue, it works as designed !