I had to do one extra step not mentioned in the documentation to get my node.js server working so I could reproduce the user login/logout notifications outlined in the example on the main module page.

After creating the symlink mentioned in step 1b:

1b. Optionally you can create a symlink:
cd /var/www/sites/all/modules/nodejs && ln -s /usr/local/lib/node/.npm/socket.io/active/package/ socket_io

I also had to make this symlink inside socket_io (this works if your document root is in /var/www, alter the path if your docroot is elsewhere)
cd /var/www/sites/all/modules/nodejs/socket_io && ln -s support/socket.io-client/

I'm rolling a patch to the README.txt now to include 1c. this perhaps optional extra step.

Comments

LSU_JBob’s picture

Status: Active » Needs review
StatusFileSize
new662 bytes

Here's the patch

Anonymous’s picture

thanks!

the way the socket.io directory and paths work is pretty sub-par - it really just grew out of me not doing it in a planned way, and i haven't fixed it yet. perhaps this issue is the place to fix it.

i think we should change the directory structure and any paths in code that require more than one symlink. so, we end up with instructions like: "1. download Socket.Io into the socket_io folder.", and it should all just work.

also, we should probably commit a directory called 'socket_io', and put a README.txt inside it.

are you ok to modify your patch along those lines?

LSU_JBob’s picture

Status: Fixed » Active

Sure.

I can make the extra directory in the project, Should we put the "optional" symlinks steps in this new socket_io/README.txt?

The two places in the code that I can see that maybe should be changed are in nodejs.module:

line 100
drupal_add_js(drupal_get_path('module', 'nodejs') . '/socket_io/support/socket.io-client/socket.io.js', array('type' => 'file'));

line 386

$defaults = array(
    'scheme' => variable_get('nodejs_server_scheme', 'http'),
    'secure' => variable_get('nodejs_server_scheme', 'http') == 'https' ? 1 : 0,
    'host' => variable_get('nodejs_server_host', 'localhost'),
    'port' => variable_get('nodejs_server_port', '8080'),
    'resource' => '/node.js/realtime',
    'authkey' => md5(session_id()),
    'serviceKey' => '',
    'websocketSwfLocation' => base_path() . drupal_get_path('module', 'nodejs') . '/socket_io/support/socket.io-client/lib/vendor/web-socket-js/WebSocketMain.swf',
  );

Those are the only places that should change when the folder setup it figured out. Correct?

Speaking of the folder setup, Are you recommending we install socket_io in a non default directory? Or try and boil down the setup to making several symlinks in the new socket_io directory?

Anonymous’s picture

Status: Needs review » Fixed

ok, updated the paths, added socket_io, added README.txt.

git pull and have a look, feel free to reopen if i broke something, or if you want better wording etc.

LSU_JBob’s picture

Can we change this step in the README.TXT:

> ln -s /path/to/socket/io/install/socket.io /path/to/your/nodejs/module/socket_io/

to

> ln -s /path/to/socket/io/install/socket.io socket.io

I created the symlink with the first command mentioned above and it made the symlink name "package" inside the socket_io directory you just created. This will cause the module to not find the socket javascript file because in line 100 of the module:
drupal_add_js(drupal_get_path('module', 'nodejs') . '/socket_io/socket.io/support/socket.io-client/socket.io.js', array('type' => 'file'));
It's looking in socket_io/socket.io.

For my personal instance, the command was:

ln -s /usr/local/lib/node/.npm/socket.io/active/package/ socket.io

Just to ensure the name of the symlink was "socket.io" and not "package".

Anonymous’s picture

Status: Active » Fixed

ah, yes, i'd forgotten about the way NPM uses symlinks.

i'd still like to keep the full path in the linkname part. thanks for the feedback, committed here:

http://drupalcode.org/project/nodejs.git/commit/33d6499

LSU_JBob’s picture

cool, I was going to suggest changing the path in the module on line 100 as an alternative, but this works just as well!

afeijo’s picture

StatusFileSize
new1.03 KB

My changes to the README.txt had the socket.io path like you used, LSU_JBob

But later I noticed that socket.io already has a symlink, so I changed it to:

/usr/local/lib/node/socket.io/

its shorter than

/usr/local/lib/node/.npm/socket.io/active/package/

:)

I attached the patch, I'll commit it after your review

LSU_JBob’s picture

I think this step should be changed to just, "Look in the socket_io directory and follow the README instructions there to symlink to your local socket.io path" ... something along those lines, Justin wrote some pretty clear symlinking directions in there.

LSU_JBob’s picture

Status: Fixed » Needs review
Anonymous’s picture

yeah, i agree with LSU_JBob - afeijo, please change it to that, and if you can see any way to make the README.txt in socket_io better, go ahead and patch it.

afeijo’s picture

Good point, I forgot the new README.txt in socket_io folder

I will change the primary README.txt, and move the socket and express installations instructions to socket_io\README.txt

ok folks?

LSU_JBob’s picture

Sounds good, post the pizzatch and we will rizzeview

afeijo’s picture

StatusFileSize
new2.73 KB

here it is, patch for both README.txt

LSU_JBob’s picture

Why did you get rid of this step?

-  3. Install npm module
-curl http://npmjs.org/install.sh | sudo sh
afeijo’s picture

StatusFileSize
new2.86 KB

I meant to move it to the socket_io/README.txt

here is the right patch

Anonymous’s picture

Status: Needs review » Reviewed & tested by the community

looks good to me, thanks afeijo

Anonymous’s picture

Status: Reviewed & tested by the community » Fixed

preparing for a beta, so i've committed this here:

http://drupalcode.org/project/nodejs.git/commit/8480b2c

thanks afeijo!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

  • Commit 33d6499 on 6.x-1.x, 7.x-1.x, drupalconlondon, auth-refactor, 8.x-1.x, 8.x-1.x-head by beejeebus:
    #1135626 by LSU_JBob: keep the directory name explicit in README.txt
    
    
  • Commit 8480b2c on 6.x-1.x, 7.x-1.x, drupalconlondon, auth-refactor, 8.x-1.x, 8.x-1.x-head by beejeebus:
    #1135626 by afeijo: improve installations instructions in README.txt...